-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Allow error handlers to be overridden #32
Comments
Unless I'm missing something, I think you could do something like this in your App::error(function(Exception $exception, $code)
{
Log::error($exception);
if ($code == '404')
{
if (Request::ajax())
return Response::json(array('error' => 'Method not found', 'code' => 404));
return View::make('error.404');
}
}); |
I suppose that certainly would work for all intents and purposes... but say I were developing a package for distribution that needed to override an error handler (like for an admin bundle or something like that), it would be great to keep that code in the package's service provider, instead of needing to modify additional areas of the code. |
Done. |
Support built-in PHP server
There are certain cases where I think developers may want to override previously defined error handlers. For example, let's say I have my main app, and also a REST API. I may want to define a 404 handler for the main app that displays a page:
If the request is to one of my API's routes though, I might want my 404s to do this:
From what I can tell, there is no way to override the default 404 handler if the request is to an API route. This was possible in L3 with
Event::override()
and it would be awesome to get an equivalent in L4.Thanks for the consideration!
The text was updated successfully, but these errors were encountered: