Reputation: 55
I'm developing a grails plugin that among other things it handles the json render of all responses for our REST APIs. We are handling some common response status as exceptions, such as bad requests, forbidden, etc. By throwing specific exceptions I then process them in an error controller and set the proper response status.
The preblem We are having is that since We are monitoring our APIs through NewRelic, all exceptions are reported as 500 errors.
I saw that in grails 2.3 you can define exception handlers on the cotrollers, and it works, but defining it one by one is out of the questions, and adding the handler through metaClass is not working.
Any ideas to solve this?
Upvotes: 1
Views: 470
Reputation: 27255
I am not sure what you mean by "defining it one by one is out of the questions" but if you mean that you don't want to add the exception handler methods in all of your controllers you have at least a couple of options. One is that you could define the exception handler methods in a base controller which all of your other controllers extend. Another option is to write an AST transformation which adds the methods to all of your controllers at compile time.
I hope that helps.
Upvotes: 1