@param \Exception $exception

@return string
770494
public function exceptionToString($exception)
    {
        $str = get_class($exception) . ': ' . $exception->getMessage() . PHP_EOL;
        $str .= '    at ' . $exception->getFile() . ':' . $exception->getLine() . PHP_EOL;
        $traces = $exception->getTraceAsString();
        $str .= preg_replace('/#\d+\s/', '    at ', $traces);

        $prev = $traces;
        $caused = $exception;
        while ($caused = $caused->getPrevious()) {
            $str .= PHP_EOL . '  Caused by ' . get_class($caused) . ': ' . $caused->getMessage() . PHP_EOL;
            $str .= '    at ' . $caused->getFile() . ':' . $caused->getLine() . PHP_EOL;
            $traces = $exception->getTraceAsString();
            if ($traces !== $prev) {
                $str .= preg_replace('/#\d+\s/', '    at ', $traces);
            } else {
                $str .= '    at ...';
            }

            $prev = $traces;
        }

        $replaces = [];
        if ($app = $this->alias->get('@root')) {
            $replaces[dirname(realpath($this->alias->get('@root'))) . DIRECTORY_SEPARATOR] = '';
        }

        return strtr($str, $replaces);
    }
156547
public function getCode(FlattenException $exception)
    {
        if (method_exists($exception, 'getStatusCode') == true) {
            $code = $exception->getStatusCode();
        } else {
            $code = $exception->getCode();
        }

        return $code;
    }
952938
public static function text(Exception $e)
    {
        return sprintf('%s [ %s ]: %s ~ %s [ %d ]', get_class($e), $e->getCode(), strip_tags($e->getMessage()), $e->getFile(), $e->getLine());
    }
705490
protected function getSafeTrace(\Exception $exception)
    {
        if (!$this->debug && !($this->session->isStarted() && $this->session->has('authentication'))) {
            return [];
        }

        $trace = $exception->getTrace();
        foreach ($trace as $key => $value) {
            $trace[$key]['args_safe'] = $this->getSafeArguments($trace[$key]['args']);

            // Don't display the full path, trim 64-char hexadecimal file names.
            if (isset($trace[$key]['file'])) {
                $trace[$key]['file'] = str_replace($this->rootPath, '[root]', $trace[$key]['file']);
                $trace[$key]['file'] = preg_replace('/([0-9a-f]{16})[0-9a-f]{48}/i', '\1…', $trace[$key]['file']);
            }
        }

        return $trace;
    }
329998
public function display(Exception $exception)
	{
		$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;

		return new Response(file_get_contents(__DIR__.'/resources/plain.html'), $status);
	}
1169916
protected function processException(Exception $e)
    {
        $this->_lastRenderError = $e;

        if ($this->_errorListener) {
            call_user_func($this->_errorListener, $e, $this);
        }

        return '';
    }
1071082
private function serializeException(\Exception $exception)
    {
        $result = [
            'code'    => $exception->getCode(),
            'message' => $exception->getMessage(),
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine(),
            'trace'   => $exception->getTraceAsString(),
        ];

        if ($exception->getPrevious() !== null) {
            $result['previous'] = $this->serializeException($exception->getPrevious());
        }

        return $result;
    }
819987
protected function formatException(\Exception $e)
	{
		if ($this->debug)
		{
			$location = $e->getMessage().' in '.$e->getFile().':'.$e->getLine();

			return 'Error in exception handler: '.$location;
		}

		return 'Error in exception handler.';
	}
512023
private function getExceptionStatusCode(\Exception $exception): int
    {
        if ($exception instanceof HttpExceptionInterface) {
            return $exception->getStatusCode();
        }

        if ($exception instanceof AccessDeniedException) {
            return $exception->getCode();
        }

        return Response::HTTP_INTERNAL_SERVER_ERROR;
    }
567699
protected function getTransformed(Exception $exception)
    {
        foreach ($this->make((array) $this->getConfigItem('transformers')) as $transformer) {
            $exception = $transformer->transform($exception);
        }

        return $exception;
    }
712051
public function withException(\Exception $exception)
    {
        assert(!is_null($exception), 'Exception must not be null');

        return $this->withDetail('error', $exception->getMessage());
    }
1128906
public function getExceptionName($exception)
    {
        if ($exception instanceof \yii\exceptions\Exception || $exception instanceof \yii\exceptions\InvalidCallException ||
            $exception instanceof \yii\exceptions\InvalidArgumentException ||
            $exception instanceof \yii\exceptions\UnknownMethodException) {
            return $exception->getName();
        }

        return null;
    }
1043083
protected function getErrorMessage(Exception $exception)
    {
        $defaultMessage =  __('Unexpected error. Please contact administrator');
        if (DEBUG_MODE) {
            $defaultMessage = $exception->getMessage();
        }
        return ($exception instanceof common_exception_UserReadableException) ? $exception->getUserMessage() :  $defaultMessage;
    }
1358547
protected function createResponseData(Exception $exception)
    {
        return $this->debug
            ? $this->extractExceptionData($exception)
            : $this->createDefaultResponseData($exception);
    }
615633
private function eventMsg(\Exception $exception)
    {
        return sprintf('%s (%s line:%s)', $exception->getMessage(), $exception->getFile(), $exception->getLine());
    }
739919
protected function renderXmlErrorMessage(Exception $exception)
    {
        $xml = "<error>\n  <message>Slim Application Error</message>\n";
        if ($this->displayErrorDetails) {
            do {
                $xml .= "  <exception>\n";
                $xml .= "    <type>" . get_class($exception) . "</type>\n";
                $xml .= "    <code>" . $exception->getCode() . "</code>\n";
                $xml .= "    <message>" . $this->createCdataSection($exception->getMessage()) . "</message>\n";
                $xml .= "    <file>" . $exception->getFile() . "</file>\n";
                $xml .= "    <line>" . $exception->getLine() . "</line>\n";
                $xml .= "    <trace>" . $this->createCdataSection($exception->getTraceAsString()) . "</trace>\n";
                $xml .= "  </exception>\n";
            } while ($exception = $exception->getPrevious());
        }
        $xml .= "</error>";

        return $xml;
    }
143915
public function getErrorMessage($exception)
    {
        $application = $this->application;
        $errorHandler = $this->runner;

        // quit if error occured
        $shouldQuit = $application->isError();

        //
        if($application instanceof Application){
            // if request type ist not strict e.g. xml or json consider error config
            if (!$application->isXmlRequest() && !$application->isJsonRequest()) {
                $shouldQuit = $shouldQuit && $application->getConfig(ApplicationInterface::KEY_ERROR, ApplicationInterface::DEFAULT_ERROR);
            }
        }

        $errorHandler->allowQuit($shouldQuit);

        $method = $errorHandler::EXCEPTION_HANDLER;
        ob_start();
        $errorHandler->$method($exception);
        $message = ob_get_clean();

        return $message;
    }