Objective-C Mapping for Local Exceptions

On this page:

Mapped Objective-C Interface

A local Slice exception is mapped to an Objective-C interface with the same name. For example:

Slice
["objc:prefix:ICE"]
module Ice
{
    local exception InitializationException
    {
        ...
    }
}

is mapped to the Objective-C interface ICEInitializationException:

Objective-C
@interface ICEInitializationException : ICELocalException
...
@end

Base Interface for Local Exceptions in Objective-C

All mapped Objective-C interfaces derive directly or indirectly from ICELocalException:

Objective-C
@interface ICELocalException : ICEException
{
@protected
    const char* file;
    int line;
}

@property(nonatomic, readonly) NSString* file;
@property(nonatomic, readonly) int line;

-(id)init:(const char*)file line:(int)line;
-(id)init:(const char*)file line:(int)line reason:(NSString*)reason;
+(id)localException:(const char*)file line:(int)line;
@end

Mapping for Local Exception Inheritance in Objective-C

A local Slice exception can extend another Slice exception. In Objective-C, this is mapped to inheritance of the corresponding interfaces. For example:

Slice
module M
{
    local exception ErrorBase {}
    local exception ResourceError extends ErrorBase {}
}

is mapped to:

Objective-C
@interface MErrorBase : ICELocalException
-(NSString *) ice_id;
+(id) errorBase:(const char*)file line:(int)line;
@end

@interface MResourceError : MErrorBase
-(NSString *) ice_id;
+(id) resourceError:(const char*)file line:(int)line;
@end