On Nov 28, 2009, at 4:25 AM, Greg Parker wrote:
> Here's a fun idiom for handling both C++ and Objective-C exceptions in the 
> same place (on iPhone and 64-bit Mac).
> 
>    @try {
>        // do stuff
>    } @catch (NSException *e) {
>        // NSException
>    } @catch (id e) {
>        // Other Objective-C exception
>    } @catch (...) {
>        // Non-ObjC exception
>        // Decode it by rethrowing it inside a C++ try/catch.
>        try {
>            @throw;
>        } catch (std::bad_cast& e) {
>            // C++ failed dynamic cast to reference type
>        } catch (...) {
>            // Other C++ exception
>            // or non-ObjC non-C++ foreign exception
>        }
>    }


I apologize if this is a dense question, but can't you just go like this?

   @try {
       // do stuff
   } @catch (NSException *e) {
       // NSException
   } @catch (id e) {
       // Other Objective-C exception
   } @catch (std::bad_cast& e) {
       // C++ failed dynamic cast to reference type
   } @catch (...) {
       // Other C++ exception
       // or non-ObjC non-C++ foreign exception
   }

-- Gwynne

_______________________________________________

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

Reply via email to