Appearance
Error Handler
All exceptions are handled by the App\Exceptions\Handler class. This class contains a render method where custom exception are reported and rendered. The below function is used to render an exception into an HTTP response.
public function render($request, Throwable $exception)
{
if ($exception instanceof PermissionDeniedException) {
$title = translate('Error Permission Denied');
return response()->view('system.errors.permissionDenied', ['title' => $title], 401);
}
if ($exception instanceof NotFoundHttpException) {
$title = translate('Not found');
return response()->view('system.errors.pageNotFound', ['title' => $title], 404);
}
if ($exception instanceof MethodNotAllowedHttpException) {
$title = translate('Method not allowed.');
return response()->view('system.errors.methodNotAllowed', ['title' => $title], 405);
}
if ($exception instanceof ResourceNotFoundException) {
$return = redirect()->back()->withErrors(['alert-danger' => 'Record was not found in our system.']);
}
if ($exception instanceof NotDeletableException) {
$return = redirect()->back()->withErrors(['alert-danger' => $exception->message]);
}
if ($exception instanceof CustomGenericException) {
$return = redirect()->back()->withErrors([$exception->alert => $exception->message]);
}
if ($exception instanceof ApiGenericException) {
$return = $this->setStatusCode($exception->statusCode)->respondWithError($exception->message);
}
if (isset($return)) {
return $return;
}
return parent::render($request, $exception);
}
During local development APP_DEBUG environment variable is set to true whereas in production its value is set to false inorder to limit the risk of exposing sensitive configuration values to application's end users.