protected function convertErrorToString(\Throwable $e, $withTrace = true) {
        $message = [
            $e->getMessage(),
            !empty($e->getFile()) ? $e->getFile() . ' #' . $e->getLine() : "",
            $e->getTraceAsString(),
        ];
        if ($withTrace) {
            $message[] = $e->getTraceAsString();
            if ($e->getPrevious() !== null) {
                $message[] = $this->convertErrorToString($e->getPrevious(), false);
            }
        }
        return implode("\n", $message);
    }