In Grails i want to catch the exception when foreign key constraint appears, this is my code
try {
instance.delete(flush:true)
flash.message = message(code : "default.deleted.message", args : [instance])
flash.level = "info"
} catch(org.springframework.dao.DataIntegrityViolationException | Exception e) {
flash.message = message(code : "default.not.deleted.message", args : [instance])
flash.level = "danger"
}
The problem is when there is a foreign key constraint, it never enters the catch block. Any idea what exception i should add ?
Thanks,