php - Why render function in ExceptionHandler in laravel dosen't execute?

307

I want to show the page500 internal server error Page but instead of showing report or render it just displays the typical Laravel exception view with the error message .

public function report(Exception $exception)
{
    parent::report($exception);
}

/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $exception
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $exception)
{

  //  $exception = FlattenException::create($exception);
    $statusCode = $exception->getStatusCode($exception);
    dd($statusCode);

    if ($statusCode === 404 or $statusCode === 500) {
        return response()->view('errors.' . $statusCode, [], $statusCode);
    }
    return parent::render($request, $exception);
}
128

Answer

Solution:

If you're seeing the woops message on 500 errors instead of a 500 error page, it is because the app is in debug mode.

In your.env file edit the following line

APP_DEBUG=true

to be

APP_DEBUG=false
651

Answer

Solution:

Could you check yourbootstrap/app.php file to see if the exception handler is bound correctly? The default configuration would be like this.

A while back I wrote a post about implementing a custom exception handler in Larvel, it might contain some useful information for your issue.

People are also looking for solutions to the problem: php - How can I remove this duplicate code in my code while still getting what I is needed

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.