Thursday, March 30, 2017

Error page not shown in some cases in Laravel 4.2

I have this function in global.php for errors

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

App::error(function(Illuminate\Database\Eloquent\ModelNotFoundException $exception)
{
    Log::error($exception);
    return Response::view('errors.missing', array(), 404);
});

This in routes.php

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

And this in controller

$user = User::where('id', $userId)->first();
if (!$user) {
        App::missing(404);
}

If I go to url like: http://example.com/user/13432 and the user with ID 13432 doesn't exist I've got 404 page.

But if I go to url like: http://example.com/user/fdsfsdfsd I've got nothing .. is staying same page. Why I don't get 404 page?



via VLS

Advertisement