views:

57

answers:

2

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?

A: 

Maybe your project/target/executable settings have been messed up? Is the "Enable Objective-C Exceptions" box ticked for your configuration/target/etc?

If it is, maybe you should file a bug with Apple here.

jv42
same code, same project configuration. I checked "Enable Objective-C Exceptions" box, it was ticked. Should I file a bug? I am an newer of Objective-C.
gwang
I would. I can't think of no reason it wouldn't work, if your test case is that simple.
jv42
A: 

I filed a bug with Apple, and the reply is:

It has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 7995323.

gwang