Norway


You might be missing the “prettier” error handler from 4. If so, here’s how to bring it back.

Update: If you’re using Laravel .2, check out this Laracasts thread on Whoops in Laravel 5.2. I’ll update this post soon with updated info, but for now just take a look there.

First, composer require filp/whoops:~1.0.

Then open /Exceptions/Handler.php, and in the render() method, add a Whoops handler in the else condition. Maybe something like this:

    /**
     * Render an exception into an HTTP response.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Exception  $e
     * @return IlluminateHttpResponse
     */
    public function render($request, Exception $e)
    {
        if ($this->isHttpException($e))
        {
            return $this->renderHttpException($e);
        }

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

        return parent::render($request, $e);
    }

    /**
     * Render an exception using Whoops.
     * 
     * @param  Exception $e
     * @return IlluminateHttpResponse
     */
    protected function renderExceptionWithWhoops(Exception $e)
    {
        $whoops = new WhoopsRun;
        $whoops->pushHandler(new WhoopsHandlerPrettyPageHandler());

        return new IlluminateHttpResponse(
            $whoops->handleException($e),
            $e->getStatusCode(),
            $e->getHeaders()
        );
    }

That’s it!

Thanks to this thread on the Laracasts forum for getting me moving in the right direction.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here