Imagine I have a service that looks like this:
public interface MyAccountService
{
boolean create( String user );
}
The method create performs several changes, namely (for discussion sake):
- adds a message into a Queue
- adds a row into several tables
- creates a LDAP account etc...
Currently I collapse all the error messages into a single boolean return value. Now internally if there is an error, I will log these for the support team.
e.g. a typical log of a failed user creation
creation of "alistair" account in the following (strict) order:
- add to table Foo: success
- add to table Bar: success
- add to LDAP: failed
- add to queue: success
This way, the tech support folks can decide how to repair the account.
What is the best practice for designing systems such that we can easily trace the success/failure of a transaction (and repair it manually) ? Is returning boolean & swallowing all exceptions a good design ? Thanks
EDIT By swallowing exceptions, I meant not throwing them up the the caller. However I do log the exceptions, and translate them to a false/true return value.