Reputation: 187
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
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 theAPP_DEBUG
environment variable, which is stored in your .env file.
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);
}
To send error messages on your email you can use this github repo.
Upvotes: 2
Reputation: 2802
Go to your config file, config/app.php and make debug to false
Documentation: Laravel Errors
Upvotes: 0