I use HessianKit to communicate with server. In the situation of network or server down Hessian will throw exception, so I put every Hessian call in a @try ... @catch block. Everything worked fine until I upgraded my xcode from 3.2.2 to 3.2.3. I wrote the some testing code and found under xcode 3.2.3, catch exception would be failed if the exception was thrown from a proxy object.
MyProxy.h:
@interface MyProxy : NSProxy {
}
@end
MyProxy.m:
@implementation MyProxy
- (id)init {
return self;
}
- (void)forwardInvocation:(NSInvocation *)invocation {
NSLog(@"Call method %@", NSStringFromSelector([invocation selector]));
[NSException raise:@"MyException" format:@"this is an exception"];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
.....
}
@end
Code using MyProxy:
@try {
MyProxy *p = [[MyProxy alloc] init];
[p doSomething];
[p release];
}
@catch (NSException * e) {
NSLog(@"%@", e);
}
When these code build under xcode 3.2.2, the exception can be catched correctly. But under xcode 3.2.3, the program terminated after output following on the console:
2010-09-08 21:09:29.877 BriefCase[34651:40b] Call method doSomgthing
2010-09-08 21:09:29.879 BriefCase[34651:40b] *** Terminating app due to uncaught exception 'MyException', reason: 'this is an exception'
2010-09-08 21:09:29.880 BriefCase[34651:40b] Stack: (
45955152,
47113004,
45692683,
45692522,
151932,
45426420,
45423090,
9352,
4417860,
4421967,
4447550,
4429047,
4461016,
53399932,
45234332,
45230248,
4420129,
4453234,
8812,
8666
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
What can I do?