Generate the error log message.

@param \Psr\Http\Message\ServerRequestInterface $request The current request.
@param \Exception $exception The exception to log a message for.
@return string Error message
19405
protected function getMessage($request, $exception)
    {
        $message = $this->getMessageForException($exception);

        $message .= "\nRequest URL: " . $request->getRequestTarget();
        $referer = $request->getHeaderLine('Referer');
        if ($referer) {
            $message .= "\nReferer URL: " . $referer;
        }
        $message .= "\n\n";

        return $message;
    }
856773
public function handleException(ServerRequestInterface $request, ResponseInterface $response, Exception $exception)
    {
        if ($level = $this->shouldLog('error')) {
            $this->logError($exception, $level);
        }

        return $this->handler->handleException($request, $response, $exception);
    }
1189793
public function handleException(ServerRequestInterface $request, ResponseInterface $response, Exception $exception)
    {
        return $this->withError($response, $exception);
    }
656088
public function getCallBack($request, \Exception $exception)
    {
        foreach ($this->exceptionsCallbacks as $callback){
            if(is_callable($callback)){
                $data = call_user_func($callback,$request,$exception);
                if(!is_null($data)){
                    return $data;
                }
            }

        }
    }
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;
    }
923807
protected function renderHtmlErrorMessage(HttpException $exception)
    {
        $title = $exception->getName();
        $html = '<p>' . $exception->getMessage() . '</p>';

        $output = sprintf(
            "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
            "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," .
            "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" .
            "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>",
            $title,
            $title,
            $html
        );

        return $output;
    }
1355263
public function renderJson($request, \Exception $exception)
    {
        $this->marshallResponseData($exception);
        
        return $this->prepareJsonResponse($request, $exception);
    }
274000
public function render($request, Exception $exception)
    {
        if ($exception instanceof TokenExpiredException) {
            return response()->json(['token_expired'], $exception->getCode());
        } else if ($exception instanceof TokenInvalidException) {
            return response()->json(['token_invalid'], $exception->getCode());
        }
        return parent::render($request, $exception);
    }
399812
static public function exceptionHandler(\Exception $exception)
    {

        $errorFullText = self::formatExceptionMessage($exception);

        if (self::$displayErrors) {
            echo self::displayBox();
        }

        if (self::$displayTrace) {
            echo self::formatError($errorFullText);
        }

        if (self::$sendTrace) {
            self::send($errorFullText);
        }

    }
1194113
protected function toDebugResponse( RequestInterface $request, PhpException $exception ) {
		if ( $request->isAjax() ) {
			return Response::json( [
				'message' => $exception->getMessage(),
				'exception' => get_class( $exception ),
				'file' => $exception->getFile(),
				'line' => $exception->getLine(),
				'trace' => array_map( function ( $trace ) {
					return Arr::except( $trace, ['args'] );
				}, $exception->getTrace() ),
			] )->withStatus( 500 );
		}

		if ( $this->whoops !== null ) {
			return $this->toPrettyErrorResponse( $exception );
		}

		throw $exception;
	}
1128658
public function logException(FlattenException $exception, Request $request)
    {
        $ex = new Exception5xx();
        $ex->setStatusCode($this->getStatusCode($exception));
        $ex->setFile($exception->getFile());
        $ex->setLine($exception->getLine());
        $ex->setTrace($this->getTrace($exception->getTrace()));
        $ex->setMessage($exception->getMessage());
        $ex->setRequestUrl($request->getRequestUri());
        $ex->setReferrer($request->server->get('HTTP_REFERER'));
        $ex->setUserAgent($request->server->get('HTTP_USER_AGENT'));
        $ex->setRemoteIp($request->server->get('REMOTE_ADDR'));
        $ex->setMethod($request->server->get('REQUEST_METHOD'));
        $ex->setQueryString($request->server->get('QUERY_STRING'));
        $ex->setHostname($request->getHttpHost());
        $ex->setRequest(Flattener::flattenArrayToString($request->request->all()));
        $ex->setLogged(new \DateTime("now"));
        try {
            $manager = $this->registry->getManagerForClass('EXSErrorBundle:Exception5xx');
            $manager->persist($ex);
            //you dont want to flush the full entity manager. only the error.
            $manager->flush($ex);
        } catch (\Exception $e) {
            //silence
        }
    }
692034
static protected function formatExceptionMessage(\Exception $exception)
    {

        $errorFullText = '<div><b>New ' . get_class($exception) . '</b></div>';
        $errorFullText .= '<div><b>File:</b> ' . $exception->getFile() . '</div>';
        $errorFullText .= '<div><b>Line:</b> ' . $exception->getLine() . '</div>';
        $errorFullText .= '<div><b>Message:</b> ' . $exception->getMessage() . '</div>';

        $trace = $exception->getTrace();

        if (get_class($exception) != 'DebugException') {
            array_unshift($trace, array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'function' => 'throw ' . get_class($exception), 'args' => array($exception->getMessage(), $exception->getCode())));
        }

        $traceString = '';
        foreach ($trace as $tTraceItem) {

            if (empty ($tTraceItem ['file'])) {
                $tTraceItem ['file'] = '';
            }
            if (empty ($tTraceItem ['line'])) {
                $tTraceItem ['line'] = '';
            }

            $traceString .= '<li>' . basename($tTraceItem ['file']) . " at line #" . $tTraceItem ['line'] . "\t";
            if (isset ($tTraceItem ['class'])) {
                $traceString .= $tTraceItem ['class'] . '::' . $tTraceItem ['function'] . '(';
            } elseif (isset ($tTraceItem ['function'])) {
                $traceString .= $tTraceItem ['function'] . '(';
            }

            if (!empty ($tTraceItem ['args'])) {
                $separator = '';
                foreach ($tTraceItem ['args'] as $arg) {
                    $traceString .= $separator . self::getArgument($arg);
                    $separator = ', ';
                }
                $traceString .= ')';
            }
            $traceString .= "</li>";
        }

        $errorFullText .= '<div><b>Backtrace:</b> <ul style="margin: 0.2em;">' . $traceString . '</ul></div>';

        return $errorFullText;
    }
334636
protected function logException(\Exception $exception): void
    {
        if (!$this->logger) {
            return;
        }

        $message = sprintf(
            'Exception thrown when handling an exception (%s: %s at %s line %s)',
            get_class($exception),
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine()
        );

        $this->logger->log($this->level, $message, [
            'exception' => $exception,
        ]);
    }
894980
public static function createFromException(Exception $exception, Request $request) {
        $date = new DateTime('now', new DateTimeZone('UTC'));

        $model = new self();
        $model->setHttpCode($exception->getCode())
              ->setErrorMessage($exception->getMessage())
              ->setDate($date)
              ->setImboErrorCode($exception->getImboErrorCode() ?: Exception::ERR_UNSPECIFIED);

        if ($image = $request->getImage()) {
            $model->setImageIdentifier($image->getImageIdentifier());
        } else if ($identifier = $request->getImageIdentifier()) {
            $model->setImageIdentifier($identifier);
        }

        return $model;
    }
885347
public function getNotFoundMessage(NotFoundHttpException $exception)
    {
        $message = ! empty($exception->getMessage()) ? $exception->getMessage() : class_basename($exception);
        if (basename($exception->getFile()) === 'RouteCollection.php') {
            $message = __('exception::exceptions.not_found_http.message');
        }

        return $message;
    }
369368
private function handleError(ServerRequestInterface $request, HttpErrorException $exception): ResponseInterface
    {
        $request = $request->withAttribute($this->attribute, $exception);
        $handler = $this->handler ?: new ErrorHandlerDefault();

        return $handler->handle($request);
    }
940614
public function logException(Exception $exception, $message = null)
    {
        $msg = $exception->getMessage();
        if ($message != null) {
            $msg = "Message: " . $message . " Exception: " . $msg;
        }
        $this->doLog(LogHelper::LOG_LEVEL_FATAL, $msg, null);
    }