Monday, March 5, 2018

how to disable laravel 5.4 default error handler - development

how to disable laravel 5.4 default error handler

I am currently working on a laravel project. I need to redirect all error pages to 404 page not found page.

public function render($request, Exception $exception)
        {
            if ($this->isHttpException($exception)) {
                switch ($exception->getStatusCode()) {

                        // not authorized
                        case '403':
                                return Response::view('404',array(),403);
                                break;

                        // not found
                        case '404':
                                return Response::view('404',array(),404);
                                break;

                        // internal error
                        case '500':
                                return Response::view('404',array(),500);
                                break;

                        default:
                                return $this->renderHttpException($exception);
                                break;
                }
        } else {
                return parent::render($request, $exception);
        }



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

Is there anyway to redirect error page to 404 page?. Also the validation errors are not displaying in this code(Redirecting to 404 when validation errors occurs). I am using the version 5.4.



from Laravel Questions and Answers https://laravelquestions.com/php/how-to-disable-laravel-5-4-default-error-handler/
via Lzo Media

No comments:

Post a Comment