No problem @cloud4bpm The response needs to be in the render method as that returns a response whilst the report should just be used for logging, sending an email, writing the error to file/database etc. You could theoretically do the logging in render but it makes sense to separate the two tasks. A method should only always really do one thing ideally.
Essentially when a request is handled errors thrown are caught and processed like so, as you can see providing a return value for report() would do nothing.
} catch (Exception $e) {
$this->reportException($e);
$response = $this->renderException($request, $e);
}
...
return $response;
}
both of those methods are in turn calling both those render/report methods with Illuminate\Contracts\Debug\ExceptionHandler being bound to App\Exceptions\Handler in the bootstrap
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
protected function reportException(Exception $e)
{
$this->app['Illuminate\Contracts\Debug\ExceptionHandler']->report($e);
}
protected function renderException($request, Exception $e)
{
return $this->app['Illuminate\Contracts\Debug\ExceptionHandler']->render($request, $e);
}
it's alway a good idea to see the docblocks for the return value it's expecting.
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/