Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 4: Route to controller when error occurred

I have a problem with laravel 4. I want to handle occurred errors like, 404 Not Found or any other errors. But I want to call a controller when such errors occurs. I've tried this:

App::missing(function($exception)
{
    return Response::view('errors.404', array('error'=>$exception), 404);
});

But actually above code is not my purpose, I want something like this:

//I know this code doesn't work, I've just wanted to show the claim
App::missing('HomeController@error');
App::error('HomeController@error');
// or ...

Is there any way to handle errors within calling a specific controller's method?

like image 712
Siamak Motlagh Avatar asked Feb 13 '23 07:02

Siamak Motlagh


1 Answers

Nothing's going to stop you from creating an instance of your controller and calling the method you want to call.

App::missing(function($exception)
{
    return App::make('HomeController')->error($exception);
});
like image 64
Kemal Fadillah Avatar answered Feb 16 '23 02:02

Kemal Fadillah