Prepare response containing exception render.

@param  \Nova\Http\Request  $request
@param  \Exception $e
@return \Symfony\Component\HttpFoundation\Response
355424
protected function prepareResponse(Request $request, Exception $e)
    {
        if ($this->isHttpException($e)) {
            return $this->createResponse($this->renderHttpException($e, $request), $e);
        } else {
            return $this->createResponse($this->convertExceptionToResponse($e, $request), $e);
        }
    }
427977
protected function createResponse($response, Exception $e)
    {
        $response = new HttpResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());

        return $response->withException($e);
    }
1097946
protected function toHttpResponse( $response, Exception $e )
	{
		$response = new Response( $response->getContent(), $response->getStatusCode(), $response->headers->all() );

		return $response->withException( $e );
	}
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);
    }
124936
public function render($request, Exception $e)
    {
        //        if ($request->isXmlHttpRequest())
//            return $this->renderXmlHttpException($e);

        if (config('app.debug')) {
            if ($request->isXmlHttpRequest()) {
                return $this->renderDebugXmlHttpException($e);
            }

            return $this->renderExceptionWithWhoops($e);
        }

        return parent::render($request, $e);
    }
987686
private function handleHttpException(HttpException $exception, Request $request) : Response
    {
        $response = new Response();

        $response->setContent($exception);
        $response->setStatusCode($exception->getStatusCode());
        $response->setHeaders($exception->getHeaders());
        $response->setHeader('Content-Type', 'text/plain');

        $event = new ExceptionCaughtEvent($exception, $request, $response);
        $this->eventDispatcher->dispatch(ExceptionCaughtEvent::class, $event);

        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);
    }
1300432
public function render($request, Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        } elseif ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        } elseif ($e instanceof AuthorizationException) {
            $e = new HttpException(403, $e->getMessage());
        } elseif ($e instanceof ValidationException && $e->getResponse()) {
            return $e->getResponse();
        }

        $fe = FlattenException::create($e);

        $handler = new SymfonyExceptionHandler(\env('APP_DEBUG', false));

        $decorated = $this->decorate($handler->getContent($fe), $handler->getStylesheet($fe));

        $response = new Response($decorated, $fe->getStatusCode(), $fe->getHeaders());

        $response->exception = $e;

        return $response;
    }
966003
public function render($request, Exception $e)
	{
		if ($e instanceof HttpException) {
			$response = $e->response();
			
			if ($request->header('Origin')) {
				Cors::attachHeaders($response);
				$response->headers->set('Access-Control-Allow-Origin', $request->header('Origin'));
			}
			
			return $response;
		}
		
		return parent::render($request, $e);
	}
238459
private function handleUncaughtException(\Throwable $exception, Request $request) : Response
    {
        $httpException = new HttpInternalServerErrorException('Uncaught exception', $exception);

        return $this->handleHttpException($httpException, $request);
    }
1050441
public static function wrapException(RequestInterface $request, \Exception $e)
    {
        return $e instanceof RequestException
            ? $e
            : new RequestException($e->getMessage(), $request, null, $e);
    }
177089
public function render($request, Exception $exception)
  {
    $exception = $this->prepare($exception);

    if ($exception instanceof ClientErrorsException) {
      return $exception->handle();
    }

    if ($exception instanceof ServerErrorsException) {
      return $exception->handle();
    }

    Events::trigger('internal.error', [$exception]);
  }
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 );
	}
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);
    }
1152111
protected function prepareResponse($request, Exception $e)
    {
        if (! $this->isHttpException($e) && config('app.debug')) {
            return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
        }

        if (! $this->isHttpException($e)) {
            $e = new HttpException(500, $e->getMessage());
        }

        return $this->toIlluminateResponse(
            $this->renderHttpException($e), $e
        );
    }
649049
public function render($request, Exception $e)
    {
        if ($this->isHttpException($e)) {
            $code = $e->getStatusCode();

            if ($code !== 500 || App::environment('production') || App::environment('staging')) {
                $page = Page::findByInternalName($code);

                if ($page) {
                    $request = Request::create($page->url()->getLocation(), 'GET');

                    return response(Route::dispatch($request)->getContent(), $code);
                }
            }
        }

        return parent::render($request, $e);
    }
301295
private function exceptionHtml(\Exception $e)
    {
        $response = new Response();
        $html = $this->render("OwsProxy3CoreBundle::exception.html.twig", array("exception" => $e));
        $response->headers->set('Content-Type', 'text/html');
        $response->setStatusCode($e->getCode() ?: 500);
        $response->setContent($html->getContent());
        return $response;
    }