Here is a simple question. Is there any possibility of, if in any case there's an error in an application and the server show us an error page, instead redirect everything to a default page ?
Covering all errors.. is that possible ?
Grails already does this for you. If an exception bubbles up to the container, it gets handled as an HTTP 500 (Internal Server Error). With conf/URLMappings.groovy
you can control what happens what happens when error statuses occur.
Here's the default mapping for 500 responses (from conf/URLMappings.groovy
):
"500"(view:'/error')
This tells the application to render the error
view, which is located in views/error.gsp
. If you want to change this, you can. You could redirect to a controller/action if you want:
// will go to 'custom' action of ErrorController, which you would create yourself
"500"(controller: "error", action: "custom")
You can configure this for any HTTP response status. See the URL Mappings documentation. If you need finer control over different exceptions that might be encountered, look at the "Declarative Error Handling" section in the referenced docs above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With