manuthalasseril
manuthalasseril

Reputation: 1064

Redirect action results error in laravel 4

I try to redirect all 404 errors by using redirect action. In routes file I add these lines

App::missing(function($exception) {
        Redirect::action('LoginController@getError');
    });

and in LoginController I have the action getError But it results an error

Error in exception handler: Route [LoginController@getError] not defined. in
D:\xampp\htdocs\mysite\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.
php:209

But I have no problem in these line

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

Please help

Upvotes: 0

Views: 686

Answers (1)

Gadoma
Gadoma

Reputation: 6565

In your second aproach you just render a view but in the first one you try to refer to a non existent route. Try defining it first, it should work. Remember to composer dump-autoload after you change routes.php

Route::get('pathwhatever/error', array('as'=>'error', 'uses' => 'LoginController@getError'));
App::missing(function($exception) {
            Redirect::action('LoginController@getError');
        });

Upvotes: 2

Related Questions