I have subclassed NSException class to create CustomException class.
Whenever I catch an exception in code (in @catch), i want to initialize an object of CustomException (subclass of NSException) with the object of NSException that is passed as a parameter to @catch.
Something like this
@catch (NSException * e) {
CustomException * ex1=[[CustomException alloc]initWithException:e errorCode:@"-11011" severity:1];
}
I tried doing it by passing the NSException object to the init method of CustomException. (i replaced the [super init] with the passed NSException object as given below)
//initializer for CustomException
-(id) initWithException:(id)originalException errorCode: (NSString *)errorCode severity:(NSInteger)errorSeverity{
//self = [super initWithName: name reason:@"" userInfo:nil];
self=originalException;
self.code=errorCode;
self.severity=errorSeverity;
return self;
}
This doen't work! How can I achieve this?
Thanks in advance