Render the exception to a response.

@param \Illuminate\Http\Request $request
@param Exception                $e

@return Response
546259
protected function renderException($request, Exception $e)
    {
        return $this->app[Handler::class]->render($request, $e);
    }
1184242
public static function display( Exception $e )
	{
		$view	= UI_HTML_Exception_View::render( $e );
		print( self::wrapExceptionView( $view ) );
	}
1079910
public function render( $request, Exception $exception ) {
        if ($this->shouldntReport($exception)) {
            return;
        }
        $message = '<h2>' . $exception->getMessage() . '</h2>';
        $message .= '<h4>' . $exception->getFile() . ' ' . $exception->getLine() . '</h4>';
        $message .= '<pre style="overflow-x: auto">' . $exception->getTraceAsString() . '</pre>';
        $message .= '<p><strong>WP-Pluginner</strong> - <em>Awesome Wordpress Plugin Framework for Laravel developers</em>';
        $message .= '<br/><a href="https://github.com/wp-pluginner/wp-pluginner" style="font-size: 12px;">https://github.com/wp-pluginner/wp-pluginner</a></p>';
        $message .= '<style type="text/css">#error-page{ max-width:90% !important;}</style>';
        wp_die($message);
    }
69390
public function render($request, Exception $e)
    {
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        }

        $debug = config('app.debug');
        /*==========  hata olduğunda mail gönder  ==========*/
        if ( ! $debug) {
            if ($this->shouldReport($e)) {
                $mail = new MailService();
                $mail->datas = $this->getEmailDatas($request, $e);
                $mail->queue();
            }

            // ilgili hata sayfası gösterilir
            $code = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 200;
            if (view()->exists($this->defaultViewPath . '.' . $code))
            {
                return response()->view($this->defaultViewPath . '.' . $code, ['code' => $code], $code);
            }
            return response()->view($this->defaultViewPath . '.default', [], $code);
        }

        return parent::render($request, $e);
    }
582355
public function render($request, Exception $e)
    {
        if ($core = $this->getCoreIfBound()) {

            if ($core->bootChecker()->isCmsWebRequest()) {
                return $this->renderCmsWebException($request, $e);
            } elseif ($core->bootChecker()->isCmsApiRequest()) {
                return $this->renderCmsApiException($request, $e);
            }
        }

        return parent::render($request, $e);
    }
737008
public static function run( \Exception $e )
	{
		$config = config('system.errors');
		if (($config['display'] || is_a( $e, Message::class )) && !($e instanceof QueryException)) {
			$obj = new Response( self::getErrorObject($e), ($e->getCode() ? $e->getCode() : 500) );
		} else {
			$obj = new Response( $e->getMessage(), 500 );
		}
		if ($config['log']) {
			self::logObject($e);
		}
		self::sendResponse( $obj );
	}
206663
private function handleForBrowser(Exception $e)
    {
//        $request = request();
//        if ($e instanceof ModelNotFoundException) {
//            $e = new NotFoundHttpException($e->getMessage(), $e);
//        }
//        elseif ($e instanceof AuthorizationException) {
//            $e = new HttpException(403, $e->getMessage());
//        }
//
//        if ($e instanceof HttpResponseException) {
//            return $e->getResponse();
//        }
//        if ($e instanceof AuthenticationException) {
//            header('Location: ' . url('auth/login'));
//            exit;
//        }
//        else if ($e instanceof ValidationException) {
//            return $this->convertValidationExceptionToResponse($e, $request);
//        }
//        else if ($request->isAjax() || $request->wantsJson()) {
//            /** @var HttpException $e */
//            return response()->json($e->getMessage(), $this->isHttpException($e) ? $e->getStatusCode() : 400);
//        }

        $data = $this->convertException($e);

        // set error title and subtitle

        if ($e instanceof HttpException) {
            // set the HTTP Response Status Text as error title
            $data['title'] = http_status_text($data['status']);

            // set the Exception class and the HTTP Response Status Code as subtitle
            $data['subtitle'] = get_class($e) . ', Status Code ' . $data['status'];
        }
        else if ($e instanceof QueryException) {
            // set title
            $data['title'] = 'SQL Error';

            // set the Exception class and error codes as subtitle
            $data['subtitle'] = get_class($e) . ' (Exception code: ' . $data['code'] . ')';
            if ($data['ansiCode'] !== null) {
                $data['subtitle'] .= ', ANSI SQLSTATE Error Code: ' . $data['ansiCode'];
            }
            if ($data['driverCode'] !== null) {
                $data['subtitle'] .= ', Driver-specific Error Code: ' . $data['driverCode'];
            }
        }
        else {
            // set error title
            $data['title'] = 'Error';

            // // set the Exception class and the Exception code as subtitle
            $data['subtitle'] = get_class($e) . ' (Exception code: ' . $data['code'] . ')';
        }

        // render the source code

        if ($e instanceof QueryException) {
            // parse the sql line from the message if exists
            if (preg_match('/at line (\d)$/', $data['message'], $match)) {
                $sqlLine = $match[1];
            }
            else {
                $sqlLine = 0;
            }
            // set the SQL Statement as source
            $data['source'] = $this->renderSQL($data['sql'], $sqlLine);
        }
        else {
            // set the PHP Code as source
            $data['source'] = $this->renderPHP($data['file'], $data['line']);
        }

        // render the trace

        $data['trace'] = $this->renderTrace($data['trace']);

        // strip the filename

        $data['file'] = $this->stripFile($data['file']);

        // choose the template

        $view = config('app.debug') ? 'errors.debug' : 'errors.default';
        if (!config('app.debug') && view()->exists('errors.' . $data['status'])) {
            $view = 'errors.' . $data['status'];
        }

        // send the response

        $headers = ($e instanceof HttpException) ? $e->getHeaders() : [];

        return response()->view($view, $data, $data['status'], $headers)->send();
    }
1303570
protected function handleException(Exception $e)
    {
        $handler = $this->app->make(ExceptionHandler::class);

        $handler->report($e);

        try {
            $handler->renderForConsole(
                $this->app->make(OutputInterface::class), $e
            );
        } catch (Throwable $e) {
            //
        }
    }
337161
protected function createActionException(\Exception $e)
    {
        $this->handleException($e);

        return new RedirectResponse($this->admin->generateUrl('list'));
    }
556775
protected function renderHttpException(HttpException $e)
	{
		$status = $e->getStatusCode();

		if (view()->exists("errors.{$status}"))
		{
			return response()->view("errors.{$status}", [], $status);
		}
		else
		{
			return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
		}
	}
113887
protected function handleException($request, Exception $e)
    {
        $this->reportException($e);

        return $this->renderException($request, $e);
    }
791935
private function generateExceptionResponse($request, Exception $e)
    {
        $formatters = $this->config['formatters'];

        // :: notation will otherwise not work for PHP <= 5.6
        $responseFactoryClass = $this->config['response_factory'];

        // Allow users to have a base formatter for every response.
        $response = $responseFactoryClass::make($e);

        foreach($formatters as $exceptionType => $formatter) {
            if (!($e instanceof $exceptionType)) {
                continue;
            }

            if (
                !class_exists($formatter) ||
                !(new ReflectionClass($formatter))->isSubclassOf(new ReflectionClass(BaseFormatter::class))
            ) {
                throw new InvalidArgumentException(
                    sprintf(
                        "%s is not a valid formatter class.",
                        $formatter
                    )
                );
            }

            $formatterInstance = new $formatter($this->config, $this->debug);
            $formatterInstance->format($response, $e, $this->reportResponses);

            break;
        }

        return $response;
    }
1273913
public function render($request, Exception $exception)
    {
        if ($exception instanceof PlatformException) {
            return $exception->toResponse();
        }

        if ($exception instanceof ValidationException) {
            return $exception->toResponse();
        }

        if ($request->isJson() && $exception->getCode()) {
            return response()->json([
                'error' => [
                    'description' => $exception->getMessage(),
                    'stack'       => $exception->getTrace(),
                ],
            ], 500);
        }

        return parent::render($request, $exception);
    }
917934
public function render($request, Exception $exception)
    {
        foreach ($this->getHandlers() as $handler) {
            if ($return = $handler->render($request, $exception)) {
                return $return;
            }
        }

        # Search throught all Handler defined in Package
        return parent::render($request, $exception);
    }
949703
public function render($request, Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        }

        if ($this->isHttpException($e)) {
            return $this->toIlluminateResponse($this->renderHttpException($e), $e);
        } else {
            return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
        }
    }
1350994
public function handle(\Exception $ex, Request $request)
    {
        foreach ($this->callbacks as $exClass => $callback) {
            if ($ex instanceof $exClass) {
                $invoker = new Invoker();
                return $invoker->invoke($callback, [], [$ex, $request]);
            }
        }
    }
121050
public function render($request, Exception $e)
    {
        $packageResponse = [];
        $statusCode = 500;
        if (($message = $e->getMessage())) {
            $packageResponse['title'] = $message;
        }
        if ($e instanceof OAuthException) {
            $e = new AccessDeniedHttpException($e->getMessage());
        }
        if ($e instanceof HttpException) {
            $statusCode = $e->getStatusCode();
        }
        if ($e instanceof ErrorMessageBagException && $e->hasErrors()) {
            $packageResponse['errors'] = $e->getErrors();
        }

        return response()->json($packageResponse, $statusCode);
    }