I have a question about error / exception handling on iPhone.
I read the documentation about the exception, and it seems that exceptions can only be used for exceptional situations.
Does this mean that you cannot use them, as in java?
for example, I'm trying to write a usage controller for my application. I have several Java examples from previous projects in this language that use exceptions in case of errors.
The question posed is simple: can I follow the example I got in Java and "translate" it into Objective-C (and use Objective-C exceptions), or is there a better way to do this?
here is the code I would like to make Objective-C friendly:
public void addPerformance(Perfomance perf) {
...
executor(new AddPerformance(perf));
}
private void executor(Usecase usecase) {
try {
UnitOfWorkServices.INSTANCE.bizTransactionStart();
usecase.execute();
UnitOfWorkServices.INSTANCE.bizTransactionCommit();
} catch (RealException re) {
UnitOfWorkServices.INSTANCE.bizTransactionEscape();
throw re;
} catch (Exception e) {
UnitOfWorkServices.INSTANCE.bizTransactionEscape();
throw new FatalException(this.getClass().getName() + " / executor("
+ usecase.getClass().getSimpleName() + ")", e,
"APPXCP_006_UNEXPECTED_EXCEPTION",
"\n\t |*| : Unexpected exception translated into FatalException");
} finally {
UnitOfWorkServices.INSTANCE.bizTransactionEnd();
}
}
.
,