How to use mach Exception handling

I wanted to perform handling for the exception in my mac and ios application, I am following this link, where it is suggested to follow either the mach exception handling or use Unix signals. I did not find many resources that could be followed to implement mach exception as suggested. Below are the few resources I could find. Can someone point to the some documentation that apple provides for this or some other helpful documentation.

https://gist.github.com/rodionovd/01fff61927a665d78ecf

I wanted to perform handling for the exception in my mac and ios application

To what end?

Folks who ask about this are usually trying to build a crash reporter. DTS doesn’t support that, and for good reason: It’s impossible to do in a reliable and sustainable way. I talk about this in gory detail in Implementing Your Own Crash Reporter.

There are, however, some supported uses for Mach exception handlers: debuggers, sophisticated language runtimes, and so on. If you post details about your final goal, I should be able to suggest a path forward.

https://gist.github.com/…

Oh, hey, I wrote that code (-:

That was back when I was more gung ho, thinking that a third-party crash reporter was a reasonable endeavour. I’m now (much) older and (arguably) wiser (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

To what end?

My primary goal to performing exception handling is that when an exception occurs, I want to be able to perform proper finalization(like closing open file handles and ports etc.) for my application before the exception causes my application to terminate. Additionally, I want to show an alert box to the user informing him about the steps to take in case the exception can be recovered like providing a restart button If that could help. I want to be able to provide a better user experience.

I want to be able to perform proper finalization (like closing open file handles and ports etc.) for my application before the exception causes my application to terminate.

There’s no point doing that. The OS will clean this stuff up for you when your process terminates.

Additionally, I want to show an alert box to the user informing him about the steps to take in case the exception can be recovered like providing a restart button If that could help.

This is not safe. The problem is that, when you app crashes, it is by definition in an undefined state. If you then try to run code that does anything complicated — and by “complicated” I mean call malloc, use Objective-C or Swift, or ever call a routine from a dynamic library that you’ve not called before — you run the risk of hitting a crash or deadlock in your code. That disrupts the state of the resulting crash report, making it hard for you to debug the original crashing problem.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to use mach Exception handling
 
 
Q