Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 0.4
-
Fix Version/s: 1.2-M2
-
Component/s: None
-
Labels:None
Description
When working outside controllers, it is very annoying to find that some domain class has not saved but you did not notice because save() fails silently.
What's more, if you're creating a class on the fly and call save, you cannot then inspect the errors anyway unless you copy the instance into a variable before calling save().
This is OK within controllers because they will typically render a view showing the errors property of the object.
A possible solution:
When the errors property is populated, set a flag. When accessing the errors property (get) clear the flag. Then make the request/session cleanup code check the flag and if its still set dump out all the validation errors to the log?
Issue Links
- is related to
-
GRAILS-4343
Add a safe save() method to Domain Objects
-
This was discussed on the mailing list and a consensus reached.
save() should throw a meaningful exception on validation failure if a convention property such as failFastSave = true is set, and this property should be set on all new generated domain classes, so that old applications do not break but all new classes protect the user from mistakes unless they knowingly disable it.