Mailing Exception logs in a live Grails webapp

前端 未结 3 489
有刺的猬
有刺的猬 2021-02-04 21:24

I\'d like my Grails web-app to send an e-mail for each exception that reaches the end-user.

Basically I\'m looking for a elegant way to achieve something equivalent to:<

3条回答
  •  渐次进展
    2021-02-04 21:42

    You could also take a look at exceptionHandler mechanism provided by Grails; I find it very simple; yet powerful enough to take care of all my custom & clean exception handling needs. Haven't tested this approach with 1.1 so far; but works very well with 1.0.3.

    class BootStrap {
    
       def exceptionHandler
    
       def init = { servletContext ->
          exceptionHandler.exceptionMappings =
            [ 'NoSuchFlowExecutionException' :'/myControler/myAction',
            'java.lang.Exception' : '/myController/generalAction']
       }
    
      def destroy = { }
    }
    

    Detailed blog here :

    http://blog.bruary.net/2008/03/grails-custom-exception-handling.html

提交回复
热议问题