Reputation: 7954
I have a problem with Exception catching in my Laravel 4 application.
I have a route like this Route::get('/articles/edit/{id}', 'ArticlesController@edit')->where('id', '[0-9]+');
Now if I go to localhost:8000/articles/edit/6
, it works fine, but if I go to localhost:8000/articles/edit/6a
it fails where clause because it has characters other than numbers, and throws NotFoundHttpException
.
I have tried to catch this exception from inside edit function as well as from routes file, but no luck. Since I am just beginning with Laravel 4 i hope to find some help here since google didn't help
Upvotes: 0
Views: 347
Reputation: 12683
You can define custom handlers for a NotFoundHttpException
by using App::missing
. From the documentation:
App::missing(function($exception)
{
return Response::view('errors.missing', array(), 404);
});
Upvotes: 1