i cant seem to find a good way to handle missing routes in Laravel5 . in laravel 4 we could use APP::missing on routes.php i have tried re-enabling routes.php and trying app::missing but it doesn't work anymore.
this is what GrahamCampbell said. "You can catch exceptions in the kernel class if you want?"
and doing this works.
public function handle($request)
{
try
{
return parent::handle($request);
}
catch (Exception $e)
{
echo \View::make('index');
exit;
// throw $e;
}
}
but i am not sure if this is the best way to do it. and even he agrees.
any suggestion/idea will be greatly appreciated, for now i am using the above code to handle http error in App\Http\Kernel
More detailed on StackOverflow.
Open up app\Http\Kernel.php
and change the content in the handle
method to this:
try
{
return parent::handle($request);
}
catch(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
return $this->app->make('Illuminate\Routing\ResponseFactory')->view('error.404', [], 404);
}
catch (Exception $e)
{
throw $e;
}
This will catch 404 Not Found exceptions and display the view file error/404.blade.php
.
I believe this is the way in Laravel 5 to catch exceptions.
@Marwelln thanks
yes that's a better way to handle this then what i did, what i did basically redirect any page errors not just 404 to index. this way at-least it will let us control which page to deploy for each types of errors.
i am gonna use this for now, i am assuming even this will change in few days hehe.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community