Skip navigation.
 
mlre: c++ exceptions causing abort
FROM : Keith Ray
DATE : Mon Dec 13 20:39:19 2004

You could write code to translate C++ exceptions into Cocoa exceptions
and vice versa, and someone already has done a lot of work for this...
see "Membrane Library" at
http://www.umbar.com/membrane/

> Message: 2
> Date: Mon, 13 Dec 2004 16:09:29 +0000
> From: Benjohn <<email_removed>>
> Subject: c++ exceptions causing abort
> To: Cocoa Dev <<email_removed>>
> Message-ID: <<email_removed>>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> Our application uses some cross platform c++ code that can throw c++
> exceptions. We would like to catch otherwise unhandled c++ exceptions
> close to the main event loop, and display a suitable error dialogue.
> This seems like it should be reasonably easy to do by using a custom
> NSApplication that replaces some methods with calls to  the super
> object wrapped in a try catch block.
>
> Having tried this though, it doesn't work. We have found that if a c++
> throw and its catch are separated by App Kit or Foundation functions,
> the catch handler isn't called, and instead the program aborts.
>
> ie:
>
>        Our c++ code                    - throw occurs here.
>        Our c++ code
>        Our c++ code
>        App Kit / Foundation
>        App Kit / Foundation
>        App Kit / Foundation
>        App Kit / Foundation
>        Our handler                    - catch here doesn't work.
>        App Kit / Foundation
>        App Kit / Foundation
>        Root of the stack
>
> We have a small project that will reproduce this.
>
> We're getting a bit desperate for a solution or explanation, and have
> failed to find any leads. I wouldn't be surprised if we had some
> compiler flags set wrong, but we've not found anything that makes a
> difference.
>
> Please could someone tell me if this is not possible (c++ exceptions
> can't be thrown through app kit / foundation methods, for eg).
> Alternatively, could someone confirm if it's definitely possible, and
> we must have something set up wrong.
>
> Thanks very much,
>        Benjohn
>

Related mailsAuthorDate
mlc++ exceptions causing abort Benjohn Dec 13, 17:09
mlRe: c++ exceptions causing abort John Stiles Dec 13, 17:40
mlRe: c++ exceptions causing abort Michael Crawford Dec 13, 19:24
mlRe: c++ exceptions causing abort Michael Crawford Dec 13, 19:24
mlRe: c++ exceptions causing abort Benjohn Dec 13, 19:53
mlRe: c++ exceptions causing abort John Stiles Dec 13, 20:38
mlre: c++ exceptions causing abort Keith Ray Dec 13, 20:39
mlre: c++ exceptions causing abort Martin Dec 14, 01:29
mlRe: c++ exceptions causing abort Benjohn Dec 14, 14:34