alpha version, October 2000
<<<even more unfinished than others>>>
...
X_DURING
...
// any code here--or called from here
// which raises an exception...
...
X_HANDLER
// ..."jumps" directly here! The current exception
// is available as "localException", you can get its
// attributes this way:
CXString *name=[localException name];
CXString *reason=[localException reason];
id userData=[localException userData]; // hardly ever used, normally nil
// if an Epoc "User::Leave()" is trapped, use this:
int leaveNo=[localException epocLeaveNumber]; // 0 for native XSdk exceptions
// or you can raise it to go to the upper level handler:
[localException raise];
X_ENDHANDLER
...
raising an exception looks like this:
...
if (error)
[CXException raise:@"name" format:@"printf-format",...];
where the name is clear, and the format and ... arguments will make the reason.
For Epoc error conditions use this:
RFile epocFile;
[CXException raiseIfError:epocFile.Open(...)];
In case you would get an advantage of the user data, raise the exception this way:
CXException *exc=[CXException exceptionWithName:@"name" userData:anyObject format:@"fmt",...];
[exc raise];
Besides, there is a macro X_UNIMPLEMENTED_METHOD, which can be used inside a method which is for historical reasons or in a beta version unimplemented: whenever such a method is called, a intelligible exception is raised.
Finally, a macro X_IGNOREEXCEPTION combines the X_HANDLER and X_ENDHANDLER.
+CXString reasonForEpocError(TInt epocError);
The method returns an intelligible description of an Epoc error. The exceptions raised through the raiseIfError method contain this description automatically, but via this method the descriptions are available anywhere.
+void raiseuserDataformat(CXString *name,id userData,CXString *fmt,...);
Primarily, the method was renamed slightly to allow convenient calling [CXException raise:@"ExcName" userData:data format:@"Fmt"].
Besides, all raised exceptions are now automatically logged (see XLog).
+CXException *exceptionWithNameuserDataformat(CXString *name,id userData,CXString *fmt,...);
+void raiseformat(CXString *name,CXString *fmt=nil,...); // makes an exception and immediately raises it
+void raiseuserDataformat(CXString *name,id userData,CXString *fmt,...); // ditto
+void raiseIfError(TInt epocLeaveNumber); // ditto, with the number, only if it is < 0
+CXException *exceptionWith(TInt epocLeaveNumber); // finds/makes an exception object inside excpt.handler
<<<documentation forthcoming>>>
Copyright © 1999-2000 X.soft, all rights reserved