the grails don’t know how to make an exception

The question and the comments below it aren’t especially clear to me but something to investigate is the root cause of the exception:

BookService bookService

try {
   def book = new Book()
   book.id = 'Lord of the Flies'
   bookSerivce.save(book)
   def anotherBook = new Book()
   anotherBook.id = 'Lord of the Flies'
   bookService.save(anotherBook)
} catch (Exception ex) {
   System.out.println(ex.getMessage())
   Throwable t = ex.getCause()
   if(t) {
        // interrogate t as the root cause
   }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top