On 12/12/2008 17:29, Joerg Barfurth wrote:
Michael Stahl schrieb:

hi,

i've got an interface to load an arbitrary number of files, where each load operation may fail independently, but any failure should not abort the whole operation. so i'd like to throw some kind of compound exception at the end if at least 1 error occurred.


That seems backwards.

If a single failure means that the entire operation is considered failed, you should abort with that single exception as soon as the error occurs. If possible roll back the things you already did first.

If failure of a suboperation is NOT a failure of the entire operation, then this should be treated as a qualified success. That means it shouldn't throw, but return, possibly passing out a tally of what worked and failed. So returning a collection of objects that describes the status of each suboperation (possibly including the exception object you caught) would seem to be the more appropriate solution.

hmm, that is also an idea i had... basically return a sequence<any>, containing all exceptions that occurred. it seems a bit weird to return exceptions :)
i'm not sure which variant i prefer.
the problem is that whether a failure is really critical or can be ignored cannot really be decided by the component that implements the interface, but only by the caller. i guess i could also add a boolean abortOnException parameter... but then the caller would be forced to think about the issue (can't default parameters in UNO IDL), which may be unnecessary overhead if he doesn't care anyway.

michael

--
"Easy reading is damned hard writing." -- Nathaniel Hawthorne


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to