protected function setTraceAndGetMessage($error, bool $appendStackTraceToMessage = false): string
    {
        $error = is_string($error) ? json_decode($error, true) : $error;

        $this->originalTrace = $error['stack'] ?? null;

        $message = $error['message'];

        if ($appendStackTraceToMessage) {
            $message .= "\n\n".$error['stack'];
        }

        return $message;
    }