Chris
Chris

Reputation: 14198

laravel get error trace of 500 response

I have a middleware that automatically logs all incoming requests. It also sends me an email when the status is 500. However, $response->getContent() only returns "Server Error" when debugging mode is disabled.

Is there some way to get more detailed information about the cause, like

$exception->getMessage() vs. $exception->getTraceAsString()

are available for the Exception class

current code:

 if($response->getStatusCode() == 500) {
            ErrorHandler::sendEmail('Incoming Request Error 500', $response->getContent());
        }

Upvotes: 0

Views: 71

Answers (1)

Brian Lee
Brian Lee

Reputation: 18187

You can interrogate the exception in the ExceptionHandler class before reporting and rendering take place: Source Line 37.

For example:

public function report(Exception $exception)
{
    logger($exception->getMessage());
    parent::report($exception);
}

Upvotes: 1

Related Questions