I am having a nasty bug show up in the wild, and I can't put my finger on it. Is there a way to have a Global Try/Catch block, or a way to handle any exception that is unhanded in Monotouch.
Can I just wrap UIApplication.Main(args)
in a try catch?
After the exception is caught, Id like to show a UIAlertView to display the results.
Any help?
The Global Exception Handler is a type of workflow designed to determine the project's behavior when encountering an execution error. Only one Global Exception Handler can be set per automation project.
An ExceptionFilterAttribute is used to collect unhandled exceptions. You can register it as a global filter, and it will function as a global exception handler. Another option is to use a custom middleware designed to do nothing but catch unhandled exceptions.
Exception handling in Ruby on Rails is similar to exception handling in Ruby. Which means, we enclose the code that could raise an exception in a begin/end block and use rescue clauses to tell Ruby the types of exceptions we want to handle.
You can wrap UIApplication.Main (args) in a try {} catch {} but you will not be able to show a UIAlertView at that point, since we've unwound the entire stack including all the UI. What you could do is log the exception to a crash file in the Documents folder of your application bundle, and show that on the next launch or upload it to a web service.
The Exceptioneer guys were working on MonoTouch support as well, which might be worth looking into.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With