Check out the failOnError option.
if( !b.save() ) {
b.errors.each {
println it
}
}
OR
try{
b.save(failOnError :true)
}catch(ValidationException e){
//handle exception
}
However I could't find any ValidationException class in the package grails.validation of grails-1.2.1.
So went for the b.errors.each approach.
Thanks for this post...
ReplyDeleteAre you aware of any such feature for dynamic get() domain method?
All I want is an exception to be thrown when there is no object for the passed id