Grails redirects page in case of error

Here is a simple question. Is there any possibility if, in any case, an error in the application and server shows us the error page and redirects everything to the default page?

Covering all errors .. maybe?

+6
source share
1 answer

Grails is already doing this for you. If a bubble occurs in the container, it is treated as HTTP 500 (Internal Server Error). Using conf/URLMappings.groovy you can control what happens when an error condition occurs.

This uses the default mapping for 500 responses (from conf/URLMappings.groovy ):

 "500"(view:'/error') 

This tells the application to display the error view, which is located in views/error.gsp . If you want to change this, you can. You can redirect to 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. See URL Mappings Documentation. If you need finer control over the various exceptions that may occur, see the “Declarative Error Handling” section in the above documents.

+6
source

Source: https://habr.com/ru/post/889479/


All Articles