Grails global error handler -


i've defined following global error handlers in urlmappings.groovy

    "404"(controller: "error", action: "notfound")     "500"(controller: "error", action: "servererror") 

the handlers implemented this:

class errorcontroller {      def notfound() {         flash.msg = "not found"         redirect uri: '/'     }      def servererror() {         flash.msg = "oops"         redirect uri: '/'     } } 

when 404 error occurs works fine, when 500 error occurs flash scope empty when redirect /. there reason why flash scope should cleared after 500 (caused uncaught exception on server)?

are sure have 1 mapping 500 error code?

make sure have 1 mapping 500 in urlmappings.groovy (remove or comment out default mapping provided grails on create-app)

static mappings = {     "404"(controller: "error", action: "notfound")     "500"(controller: "error", action: "servererror")      "/"(view:"/index") //or whichever view have root context.     //"500"(view:'/error') [culprit] } 

it should work expected above url mapping.

well placing matters, if place custom mapping 500 after default mapping provided grails, see result expected. last mapping overrides older one.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -