Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-20 Thread Matt Neuburg
On Sat, 19 Dec 2009 13:27:01 +0200, Oleg Krupnov 
said:

>Anyway, I have just found that the following code works:
>
>NSExceptionHandler *handler = [NSExceptionHandler defaultExceptionHandler];
> [handler setExceptionHandlingMask:NSLogAndHandleEveryExceptionMask];
> [handler setDelegate:self];
>
>The delegate method DOES get called:
>
>- (BOOL)exceptionHandler:(NSExceptionHandler *)sender
>shouldHandleException:(NSException *)exception mask:(unsigned
>int)aMask
>{ [NSApp reportException:exception];
> return YES;

But this has nothing to do with Snow Leopard. I've got projects going back
many years that use that code. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-19 Thread Oleg Krupnov
Thanks Ken,

By "uncaught" I mean an exception for which I do not set any handlers
in my own code, and let it bubble up until it is handled by some
default mechanism, be it NSApp default handler, NSExceptionHandler,
NSSetUncaughtExceptionHandler or whatever. AFAIU, in Cocoa apps, it's
NSApp that intercepts these exceptions, so that the
NSSetUncaughtExceptionHandler handler never gets called. On Leopard,
[NSApp reportException] used to be a valid way of "injecting my code",
but it no longer gets called on Snow Leopard. :(

I am testing an exception produced by NSAssert, that is
NSInternalInconsistencyException. It doesn't seem to be a C++
exception to me, is it?


Anyway, I have just found that the following code works:

NSExceptionHandler *handler = [NSExceptionHandler defaultExceptionHandler];
[handler setExceptionHandlingMask:NSLogAndHandleEveryExceptionMask];
[handler setDelegate:self];

The delegate method DOES get called:

- (BOOL)exceptionHandler:(NSExceptionHandler *)sender
shouldHandleException:(NSException *)exception mask:(unsigned
int)aMask
{   [NSApp reportException:exception];
return YES;
}

However, somehow the [exception callStackReturnAddresses] is nil,
which is now another problem for me :(

Oleg.



On Sat, Dec 19, 2009 at 1:15 PM, Ken Thomases  wrote:
> On Dec 19, 2009, at 4:56 AM, Oleg Krupnov wrote:
>
>> On Fri, Dec 18, 2009 at 1:48 AM, Ken Thomases  wrote:
>>>
>>> On Dec 17, 2009, at 8:41 AM, Oleg Krupnov wrote:
>>>
 On Leopard, I used to override [NSApp reportException:] method to
 track all uncaught exceptions that occur in my app.

 However, I have just discovered that on Snow Leopard, this method
 never gets called. Instead, the application handles the exception
 somewhere inside and I only get this message in the console:

 HIToolbox: ignoring exception 'Test crash' that raised inside Carbon
 event dispatch

 How to work around this and receive the uncaught exceptions somehow?
>>>
>>> Have you looked at the NSExceptionHandler class and the accompanying
>>> guide?
>>
>> Yes, I tried it but it does not seem to have any effect.
>>
>> I checked the [[NSExceptionHandler defaultExceptionHandler]
>> exceptionHandlingMask], and it's 0. I tried to set it to various
>> combinations, but nothing changes in the behavior of the app.
>>
>> I also tried NSSetUncaughtExceptionHandler, but it does not work either.
>>
>> Any ideas? Thanks!
>
> On taking a second look at the particular exception, it's inside HIToolbox
> and Carbon.  It's almost surely a C++ exception.  It won't be visible to the
> Cocoa/Objective-C exception handling mechanisms.  Also, I don't believe
> there's any way to inject your own handling between the point where it's
> thrown and caught if that's all inside of code you don't control.  You
> should be able to break on the C++ throw in the debugger, though.
>
> Also, you keep referring to the exception as uncaught when it clearly is
> caught.  What do you think is logging that message if not an exception
> handler?
>
> Regards,
> Ken
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-19 Thread Ken Thomases

On Dec 19, 2009, at 4:56 AM, Oleg Krupnov wrote:

On Fri, Dec 18, 2009 at 1:48 AM, Ken Thomases   
wrote:

On Dec 17, 2009, at 8:41 AM, Oleg Krupnov wrote:


On Leopard, I used to override [NSApp reportException:] method to
track all uncaught exceptions that occur in my app.

However, I have just discovered that on Snow Leopard, this method
never gets called. Instead, the application handles the exception
somewhere inside and I only get this message in the console:

HIToolbox: ignoring exception 'Test crash' that raised inside Carbon
event dispatch

How to work around this and receive the uncaught exceptions somehow?


Have you looked at the NSExceptionHandler class and the  
accompanying guide?


Yes, I tried it but it does not seem to have any effect.

I checked the [[NSExceptionHandler defaultExceptionHandler]
exceptionHandlingMask], and it's 0. I tried to set it to various
combinations, but nothing changes in the behavior of the app.

I also tried NSSetUncaughtExceptionHandler, but it does not work  
either.


Any ideas? Thanks!


On taking a second look at the particular exception, it's inside  
HIToolbox and Carbon.  It's almost surely a C++ exception.  It won't  
be visible to the Cocoa/Objective-C exception handling mechanisms.   
Also, I don't believe there's any way to inject your own handling  
between the point where it's thrown and caught if that's all inside of  
code you don't control.  You should be able to break on the C++ throw  
in the debugger, though.


Also, you keep referring to the exception as uncaught when it clearly  
is caught.  What do you think is logging that message if not an  
exception handler?


Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-19 Thread Oleg Krupnov
Yes, I tried it but it does not seem to have any effect.

I checked the [[NSExceptionHandler defaultExceptionHandler]
exceptionHandlingMask], and it's 0. I tried to set it to various
combinations, but nothing changes in the behavior of the app.

I also tried NSSetUncaughtExceptionHandler, but it does not work either.

Any ideas? Thanks!

On Fri, Dec 18, 2009 at 1:48 AM, Ken Thomases  wrote:
> On Dec 17, 2009, at 8:41 AM, Oleg Krupnov wrote:
>
>> On Leopard, I used to override [NSApp reportException:] method to
>> track all uncaught exceptions that occur in my app.
>>
>> However, I have just discovered that on Snow Leopard, this method
>> never gets called. Instead, the application handles the exception
>> somewhere inside and I only get this message in the console:
>>
>> HIToolbox: ignoring exception 'Test crash' that raised inside Carbon
>> event dispatch
>>
>> How to work around this and receive the uncaught exceptions somehow?
>
> Have you looked at the NSExceptionHandler class and the accompanying guide?
>
> Cheers,
> Ken
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-17 Thread Ken Thomases
On Dec 17, 2009, at 8:41 AM, Oleg Krupnov wrote:

> On Leopard, I used to override [NSApp reportException:] method to
> track all uncaught exceptions that occur in my app.
> 
> However, I have just discovered that on Snow Leopard, this method
> never gets called. Instead, the application handles the exception
> somewhere inside and I only get this message in the console:
> 
> HIToolbox: ignoring exception 'Test crash' that raised inside Carbon
> event dispatch
> 
> How to work around this and receive the uncaught exceptions somehow?

Have you looked at the NSExceptionHandler class and the accompanying guide?

Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-17 Thread Vera Tkachenko

On 17 груд. 2009, at 16:44, Oleg Krupnov wrote:

> On Leopard, I used to override [NSApp reportException:] method to
> track all uncaught exceptions that occur in my app.
> 
> ...
> 
> How to work around this and receive the uncaught exceptions somehow?
> 
> Thanks!



You can take a look at this project  for examples of source code - 
http://github.com/tcurdt/feedbackreporter

Thanks,
Vera Tkachenko

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Can't trap uncaught exceptions on Snow Leopard

2009-12-17 Thread Oleg Krupnov
On Leopard, I used to override [NSApp reportException:] method to
track all uncaught exceptions that occur in my app.

However, I have just discovered that on Snow Leopard, this method
never gets called. Instead, the application handles the exception
somewhere inside and I only get this message in the console:

HIToolbox: ignoring exception 'Test crash' that raised inside Carbon
event dispatch

How to work around this and receive the uncaught exceptions somehow?

Thanks!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com