When an exception is generated in server responds to client with status “500” and using this response code we display a message to enduser through UrlMapping like:

"500"(controller:"error", action:"display")

We can customize this message by accessing the exception in our error controller as

request.exception

Top level exception always points to the controller where it was thrown so we can find out the controller name with exception.className and we can display the error message per controller basis.

class ErrorController{
def display () {
  def exception = request.exception
 render(text: "Thare is an exception in ${exception?.className}")
    }
}