Converts an Exception to String

@param \Exception $exception

@return string[]
10399
private function normalizeException(\Exception $exception) {
		$data = [
			'class'   => get_class($exception),
			'message' => $exception->getMessage(),
			'code'    => $exception->getCode(),
			'file'    => $exception->getFile() . ':' . $exception->getLine(),
		];
		$trace = $exception->getTraceAsString();
		$data['trace'] = $trace;

		$previous = $exception->getPrevious();
		if ($previous) {
			$data['previous'] = $this->normalizeException($previous);
		}

		return $data;
	}
1152121
public function formatException(Exception $exception)
    {
        if ($exception instanceof HttpException) {
            return $this->formatter->formatResponse($exception->getResponse());
        }

        if ($exception instanceof TransferException || $exception instanceof NetworkExceptionInterface) {
            return sprintf('Transfer error: %s', $exception->getMessage());
        }

        return sprintf('Unexpected exception of type "%s": %s', get_class($exception), $exception->getMessage());
    }
1361344
public function getException($exception)
    {
        return array(
          'type' => 'exception',
          'tid' => $this->tid,
          'action' => $this->action,
          'method' => $this->method,
          'message' => $exception->getMessage(),
          'where' => $exception->getTraceAsString()
        );
    }
604586
protected static function makeExceptionContent(\Exception $exception)
    {
        if ($exception instanceof DfException) {
            return ['error' => $exception->toArray()];
        }

        $errorInfo['code'] = ($exception->getCode()) ?: ServiceResponseInterface::HTTP_INTERNAL_SERVER_ERROR;
        $errorInfo['message'] = htmlentities($exception->getMessage());

        if (config('app.debug', false)) {
            $trace = $exception->getTraceAsString();
            $trace = str_replace(["\n", "#"], ["", "<br>"], $trace);
            $traceArray = explode("<br>", $trace);
            $cleanTrace = [];
            foreach ($traceArray as $k => $v) {
                if (!empty($v)) {
                    $cleanTrace[] = $v;
                }
            }
            $errorInfo['trace'] = $cleanTrace;
        }

        return ['error' => $errorInfo];
    }
278240
protected function getStatusCode(\Exception $exception)
    {
        // If matched
        if ($statusCode = $this->exceptionCodes->resolveException($exception)) {
            return $statusCode;
        }

        // Otherwise, default
        if ($exception instanceof HttpExceptionInterface) {
            return $exception->getStatusCode();
        }

        return 500;
    }
191799
protected function prepareReplacements(Exception $exception)
    {
        $statusCode = $this->getStatusCode($exception);

        if (! $message = $exception->getMessage()) {
            $message = \sprintf('%d %s', $statusCode, Response::$statusTexts[$statusCode]);
        }

        $replacements = [
            ':message' => $message,
            ':status_code' => $statusCode,
        ];

        if ($exception instanceof MessageBagErrors && $exception->hasErrors()) {
            $replacements[':errors'] = $exception->getErrors();
        }

        if ($exception instanceof ValidationException) {
            $replacements[':errors'] = $exception->errors();
            $replacements[':status_code'] = $exception->status;
        }

        if ($code = $exception->getCode()) {
            $replacements[':code'] = $code;
        }

        if ($this->runningInDebugMode()) {
            $replacements[':debug'] = [
                'line' => $exception->getLine(),
                'file' => $exception->getFile(),
                'class' => \get_class($exception),
                'trace' => \explode("\n", $exception->getTraceAsString()),
            ];

            // Attach trace of previous exception, if exists
            if (! \is_null($exception->getPrevious())) {
                $currentTrace = $replacements[':debug']['trace'];

                $replacements[':debug']['trace'] = [
                    'previous' => \explode("\n", $exception->getPrevious()->getTraceAsString()),
                    'current' => $currentTrace,
                ];
            }
        }

        return \array_merge($replacements, $this->replacements);
    }
1179595
public static function ConvertToString (\Exception $e) {
		return sprintf(
			'#message %s %s(%s) %s',
			static::ConvertinternalEncoding($e->getMessage()),
			static::ConvertinternalEncoding($e->getFile()),
			$e->getLine(),
			static::ConvertinternalEncoding(str_replace(array("\n", "\r", "\r\n"), " ", $e->getTraceAsString()))
		);
	}
882355
protected function getClass(\Exception $exception)
    {
        $message = '';

        if (($previous = $exception->getPrevious())) {
            $message = $this->getClass($previous) . ' < '; // Recurse
        }

        // Let the exception lie about its class: to support marshalling exceptions
        if (method_exists($exception, 'getClass')) {
            $message .= $exception->getClass();
        } else {
            $message .= get_class($exception);
        }

        return $message;
    }
589842
protected function getCode(\Exception $exception)
    {
        return $exception instanceof \ErrorException ?
            $this->getHumanErrorCode($exception->getSeverity()) :
            $exception->getCode()
        ;
    }
1071821
private function cleanExceptions(Exception $exception)
    {
        $exceptions = [];

        do {
            $exceptions[] = [
                'class'         => get_class($exception),
                'exception'     => new ObjectStub($exception),
                'message'       => $exception->getMessage(),
                'code'          => $exception->getCode(),
                'file'          => $exception->getFile(),
                'line'          => $exception->getLine(),
                'traceAsString' => $exception->getTraceAsString(),
                'trace'         => new SerializableValueStub($exception->getTrace()),
            ];
        } while ($exception = $exception->getPrevious());

        return $exceptions;
    }
1193353
private function getExceptionData($exception)
    {
        $data = [];

        $data['enviroment'] = env('APP_ENV');
        $data['host'] = Request::server('SERVER_NAME');
        $data['method'] = Request::method();
        $data['fullUrl'] = Request::fullUrl();
        $data['exception'] = $exception->getMessage();
        $data['error'] = $exception->getTraceAsString();
        $data['line'] = $exception->getLine();
        $data['file'] = $exception->getFile();
        $data['class'] = get_class($exception);
        $data['storage'] = [
            'SERVER' => Request::server(),
            'GET' => Request::query(),
            'POST' => $_POST,
            'FILE' => Request::file(),
            'OLD' => Request::hasSession() ? Request::old() : [],
            'COOKIE' => Request::cookie(),
            'SESSION' => Request::hasSession() ? Session::all() : [],
            'HEADERS' => Request::header(),
        ];

        $data['storage'] = array_filter($data['storage']);

        $count = $this->config['count'];
        $lines = file($data['file']);
        $data['exegutor'] = [];

        for ($i = -1 * abs($count); $i <= abs($count); $i++) {
            $data['exegutor'][] = $this->getLineInfo($lines, $data['line'], $i);
        }
        $data['exegutor'] = array_filter($data['exegutor']);

        // to make symfony exception more readable
        if ($data['class'] == 'Symfony\Component\Debug\Exception\FatalErrorException') {
            preg_match("~^(.+)' in ~", $data['exception'], $matches);
            if (isset($matches[1])) {
                $data['exception'] = $matches[1];
            }
        }

        return $data;
    }
131728
function _exceptionHandler($exception)
    {
        $result['message'] = $exception->getMessage();

        if (self::$_config['errors']['exceptionBacktrace']) {
            $result['backtrace'] = $this->convertTrace($exception->getTrace());
        }

        $result['string'] = $exception->getTraceAsString();
        $result['code']   = $exception->getCode();

        if ($this->_isLiteMode()) {
            $this->_dumpRenderLite(PHP_EOL . $result['string'], '** EXCEPTION / ' . $this->_htmlChars($result['message']));

        } else {
            $this->_initAssets(true);
            $this->dump($result, '<b style="color:red;">**</b> EXCEPTION / ' . $this->_htmlChars($result['message']));
        }

        return true;
    }
172355
protected function getStatusCode(Exception $exception)
    {
        if ($exception instanceof ValidationException) {
            return $exception->status;
        }

        return $this->getExceptionStatusCode($exception);
    }
1105362
protected static function getFirstException(\Exception $exception)
    {
        if (null !== $exception->getPrevious()) {
            return static::getFirstException($exception->getPrevious());
        }

        return $exception;
    }
182881
public function getNormalized(\Exception $exception)
    {
        $stack = $exception->getTrace();
        $trace = [];

        foreach ($stack as $item) {
            $trace[] = [
                'invocation' => $this->getInvocation($item),
                'origin'     => $this->getOrigin($item)
            ];
        }

        return $trace;
    }
1134472
protected function convertExceptionToArray(Exception $exception): array
    {
        $errors = [
            'exception' => get_class($exception),
            'file' => $exception->getFile(),
            'line' => $exception->getLine(),
            'trace' => collect($exception->getTrace())->map(function ($trace) {
                return Arr::except($trace, ['args']);
            })->all(),
        ];

        return [
            'message' => $exception->getMessage() ?: 'Server error',
            'errors' => config('app.debug') ? $errors : [],
        ];
    }
300190
protected function extractExceptionProperties(\Throwable $exception): array
    {
        $previous = $exception->getPrevious();

        return [
            '$message' => $exception->getMessage(),
            '$file' => $exception->getFile(),
            '$code' => $exception->getCode(),
            '$line' => $exception->getLine(),
            '$previous' => $previous ? $this->extractExceptionProperties($previous) : null,
        ];
    }