Walker Base
Walker Base

Reputation: 187

Laravel if error page, then redirect back

I am going to try to public my laravel project, but sometimes since i cant test all the step cases so it may encounter error with a whole page of error message

How can i redirect back if encounter error? at least it can avoid user experience losing, i dont want users able to see the error message

(it is better if it can automatic report to my server with error message) but at least dont let user see the error page

thanks!

Upvotes: 0

Views: 1924

Answers (2)

Amit Gupta
Amit Gupta

Reputation: 17658

In your .env file on the production server, you can set APP_DEBUG=false.

The debug option in your config/app.php configuration file determines how much information about an error is actually displayed to the user. By default, this option is set to respect the value of the APP_DEBUG environment variable, which is stored in your .env file.

Docs

If you want to redirect user on exceptions then you can do this in the render() method of App\Exceptions\Handler class

For example:

public function render($request, Exception $exception)
{
    if ($exception instanceof CustomException) {
        return redirect()->to('your_url');
    }

    return parent::render($request, $exception);
}

Docs

To send error messages on your email you can use this github repo.

Upvotes: 2

Med
Med

Reputation: 2802

Go to your config file, config/app.php and make debug to false

Documentation: Laravel Errors

Upvotes: 0

Related Questions