Render the exception into an HTTP response.

@param \Illuminate\Http\Request $request The request object.

@return mixed
356015
public function render($request)
    {
        if ($request->wantsJson()) {
            return $this->validInternalServerErrorJsonResponse($this, $this->message);
        } else {
            return redirect()->back()->with(['rafflesargentina.status.error' => $this->message]);
        }
    }
214392
public function handle(Request $request)
    {
        $response = new Response();
        $response = $this->executePassiveActions($request, $response);
        $response = $this->executeAction($request, $response);

        if ($response->isClientError() || $response->isServerError()) {
            return $this->handleError($request, $response);
        }

        return $response;
    }
1279098
public function sendRequest(Request $request)
    {
        $response = $this->httpClient->send($request);

        $this->checkErrorResponse($response);

        return $response;
    }
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);
    }
164768
public function handle(Request $request)
	{
		$response = $this->next($request);

		$class = $this->app->get('arguments')->get('class');
		$task  = $this->app->get('arguments')->get('task');

		$command   = new $class($this->app->get('output'), $this->app->get('arguments'));
		$shortName = strtolower(with(new \ReflectionClass($command))->getShortName());

		// Fire default before event
		Event::fire($shortName . '.' . 'before' . ucfirst($task));

		$command->{$task}();

		// Fire default after event
		Event::fire($shortName . '.' . 'after' . ucfirst($task));

		$this->app->get('output')->render();

		return $response;
	}
874128
protected function doRequest(Request $request)
    {

        $this->client->send($request, $response = new Response());

        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);
    }
659244
public function indexAction(Request $request)
    {

        /** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
        $phpCache = $this->get('networking_init_cms.lib.php_cache');

        /** @var PageSnapshotInterface $page */
        $page = $request->get('_content');

        $template = $request->get('_template');
        if ($template instanceof \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template) {
            $template = $template->getTemplate();
        }
        $user = $this->getUser();

        if ($phpCache->isCacheable($request, $user) && $page instanceof PageSnapshotInterface) {
            if (!$this->isSnapshotActive($page)) {
                throw new NotFoundHttpException();
            }

            if ($this->getSnapshotVisibility($page) != PageInterface::VISIBILITY_PUBLIC) {
                if (false === $this->get('security.authorization_checker')->isGranted('ROLE_USER')) {
                    throw new AccessDeniedException();
                }
            }

            $updatedAt = $phpCache->get(sprintf('page_%s_created_at', $page->getId()));
            $cacheKey = $request->getLocale().$request->getPathInfo();

            if ($updatedAt != $page->getSnapshotDate()) {
                $phpCache->delete($cacheKey);
            }

            $response = $phpCache->get($request->getLocale().$request->getPathInfo());

            if (!$response || !$response instanceof Response) {
                $params = $this->getPageParameters($request);

                if ($params instanceof RedirectResponse) {
                    return $params;
                }
                $html = $this->renderView(
                    $template,
                    $params
                );
                $response = new Response($html);

                $phpCache->set($cacheKey, $response);
                $phpCache->set(sprintf('page_%s_created_at', $page->getId()), $page->getSnapshotDate());
            } else {
                $phpCache->touch($cacheKey);
                $phpCache->touch(sprintf('page_%s_created_at', $page->getId()));
            }
        } else {
            $params = $this->getPageParameters($request);

            if ($params instanceof RedirectResponse) {
                return $params;
            }
            $html = $this->renderView(
                $template,
                $params
            );
            $response = new Response($html);
        }

        if ($this->getPageHelper()->isAllowLocaleCookie() && !$this->getPageHelper()->isSingleLanguage()) {
            $response->headers->setCookie(new Cookie('_locale', $request->getLocale()));
        }

        return $response;
    }
1273652
public function render($request, Exception $e)
    {
        if (app()->environment() == 'testing') {
            throw $e;
        }
        if ($e instanceof NotFoundHttpException) {
            if ($request->method() == "GET") {
                return array_key_exists('extension', pathinfo(array_key_exists('path', $parsed = parse_url($request->url()))
                        ? $parsed['path']
                        : null))
                    ? errors(['Not Found'], 404)
                    : html()->generate(); 
            } 
            return errors(['Not Found'], 404);
        }
        if ($e instanceof MethodNotAllowedHttpException) {
            if ($request->method() == "GET") {
                return html()->generate();
            }  
            return parent::render($request, $e);          
        }
        if (app()->environment() == 'local') {
            return errors([$e->getMessage(), $e->getFile() . ': line ' . $e->getLine()], 500);
        }
        return errors([$e->getMessage()], 500);
    }
113887
protected function handleException($request, Exception $e)
    {
        $this->reportException($e);

        return $this->renderException($request, $e);
    }
652014
public function render($request, Exception $e)
    {
        // Verificar se deve responser como API
        if (app()->runningWebApi()) {
            return $this->renderApi($request, $e);
        }

        // Exceções Http
        if ($e instanceof HttpException) {
            if (! is_null($this->viewService)) {
                // Veriifcar se foi implemetado uma view no app
                $view = 'errors.' . $e->getStatusCode();
                if ($this->getViewService()->exists($view)) {
                    return $this->getViewService()->make($view)->render();
                }

                // Verificar se foi implememtado uma view no theme
                $view = 'theme::errors.' . $e->getStatusCode();
                if ($this->getViewService()->exists($view)) {
                    return $this->getViewService()->make($view)->render();
                }
            } else {
                $message = $e->getMessage();
                $message = ($message == '') ? $e->getStatusCode() : $message;
                return 'error: ' . $message;
            }
        }

        // ErrorsException
        if ($e instanceof ErrorsException) {
            $back = redirect()->back()->withInput()->withErrors($e->getErrors(), $e->getMessage());

            return $back;
        }


        return 'error: ' . $e->getMessage();
    }
846472
public function handle($request)
    {
        $this->loadAuthManager();
        
        try {
            $response = $this->sendRequestThroughRouter($request);
            $response = $response->getContent();
            
            $json = json_decode($response, true);
            if (json_last_error() == JSON_ERROR_NONE) {
                $response = $json;
            }
        } catch (Exception $e) {
            if ($e instanceof NotFoundHttpException) {
                $response = $e;
            } else {
                throw $e;
            }
        }
        
        $this->app['events']->fire('wskernel.handled', [$request, $response]);
        
        return $response;
    }
1146406
public function render($request, Exception $exception)
    {
        // Convert all non-http exceptions to a proper 500 http exception
        // if we don't do this exceptions are shown as a default template
        // instead of our own view in resources/views/errors/500.blade.php
        if ($this->shouldReport($exception) && !$this->isHttpException($exception) && !config('app.debug')) {
            $exception = new HttpException(500, 'Whoops!');
        }

        return parent::render($request, $exception);
    }
1245190
public function viewAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $this->isGrantedOr403($configuration, ResourceActions::SHOW);

        /** @var DefinedTranslationInterface|TemplateAwareInterface|ResourceInterface $resource */
        $resource = $this->findOr404($configuration);

        $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $resource);

        $view = View::create($resource);

        if ($configuration->isHtmlRequest()) {
            $template = $resource->getTemplate();

            if ($template) {
                $tpl = $resource->getTemplateName();
                $options = $template->getOptions();
            } else {
                $tpl = $configuration->getTemplate(ResourceActions::SHOW.'.html');
                $options = [];
            }

            $this->addTranslations($resource);

            $view
                ->setTemplate($tpl)
                ->setTemplateVar($this->metadata->getName())
                ->setData(
                    [
                        'configuration' => $configuration,
                        'metadata' => $this->metadata,
                        'resource' => $resource,
                        'tpl' => ['options' => $options],
                        $this->metadata->getName() => $resource,
                    ]
                );
        }

        return $this->viewHandler->handle($configuration, $view);
    }
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;
    }
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);
    }
956443
public function render($request)
    {
        if (str_is('api.*', $request->getHost()) || $request->wantsJson()) {
            return response()->json(['message' => $this->getMessage()], 400);
        }
        return abort(500, '<strong>Whoops!</strong> Something went wrong!');
    }