A base exception class is defined as the super class for all external exceptions. Specific exceptions always inherit from the base exception. To enable you, the Object API developer, to write a standard exception handler, all external exceptions have an error code and a single error message. Furthermore, the exception may contain another exception as the cause. See the Developer Guide: Device Client Error Reference for detailed information.
/*!
@class SUPBaseException
@abstract This class contains information about the exception, error code and error messages.
@discussion
*/
@interface SUPBaseException : NSException {
NSArray* _arguments;
int _errorCode;
NSException* _cause;
}
// the error code property
@property(readwrite, assign, nonatomic) int errorCode;
// the root exception
@property(readwrite, retain, nonatomic) NSException* cause;
// localized error message
@property(readwrite, copy, nonatomic) NSString* message;
...
/*!
@method messageWithLocale
@abstract get the error message using the locale specified
@result the localized message
@discussion
*/
- (NSString *)messageWithLocale:(NSString *)locale;
@end;
You can use the message and messageWithLocale(String locale) methods to retrieve an error message for a specified locale. message is the NSString* message property and messageWithLocale is the messageWithLocale:NSString* locale method.
@try
{
// …
}
@catch (SUPBaseException *e)
{
NSString* errorMessage = e.message;
NSString* errorMessageSpanish = [e messageWithLocale:@"es"];
}
See the Object API Applications section of the Developer Guide: Device Client Error Reference for information about possible error codes and the corresponding error messages.