php - laravel 4: Route to controller when error occurred -
i have problem laravel 4
. want handle occurred errors like, 404 not found
or other errors. want call controller when such errors occurs. i've tried this:
app::missing(function($exception) { return response::view('errors.404', array('error'=>$exception), 404); });
but above code not purpose, want this:
//i know code doesn't work, i've wanted show claim app::missing('homecontroller@error'); app::error('homecontroller@error'); // or ...
is there way handle errors within calling specific controller's method?
no, can't use app::missing('controller@method')
directly because missing
method calls error
method , is:
public function error(closure $callback) { $this['exception']->error($callback); }
it accepts closure may call controller
->method
closure. so. declare handler using closure usual , call controller's method within closure.
as side note, don't see importance call method controller through/within closure because may same thing (most you'll return view) closure why layer ?
update:
app::missing(function($e){ // use model here want $var = 'somevalue' model return response::view('errors.404', array('error'=> $e, 'another' => $var)); });
Comments
Post a Comment