Hello, Just digging up a 12 year old thread on a different list here...
http://webobjects-dev.omnigroup.narkive.com/qCLbaSnX/throwing-multiple-validation-errors-during-validateforsave Chuck suggests something like the following: public void validateForSave() throws ValidationException { NSMutableArray exceptions = new NSMutableArray(); try { super.validateForSave(); } catch (ValidationException e) { exceptions.addObjectsFromArray(e.additionalExceptions()); } // ... if (exceptions.count() > 0) { throw ValidationException.aggregateExceptionWithExceptions(exceptions); } } Chuck, does that miss the case where super.validateForSave() just throws a single exception e without nested exceptions? In that case, e.additionalExceptions() will return an empty array, and e doesn't get added to the exceptions array. That seems to be what's happening for me, anyway. I don't think this would be quite right: try { super.validateForSave(); } catch (ValidationException e) { exceptions.add(e); exceptions.addObjectsFromArray(e.additionalExceptions()); } because the Javadocs suggest the container exception duplicates the first exception in the array. http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/foundation/NSValidation.ValidationException.html#aggregateExceptionWithExceptions(com.webobjects.foundation.NSArray) How about this? try { super.validateForSave(); } catch (ValidationException e) { if (e.additionalExceptions().count() > 0) { exceptions.addObjectsFromArray(e.additionalExceptions()); } else { exceptions.add(e); } } I'll test it out, but if someone already knows, by all means jump in. -- Paul Hoadley http://logicsquad.net/
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com