Exception Handling

Mono's exception handling contains methods to create `MonoException*` objects that can be raised.

Alternatively, you can obtain an exception that you can raise from some of the most common exceptions in the .NET Runtime.

Raising and Catching exceptions

If you plan on running your code in Mono's Cooperative mode for the Garbage Collector (for example, if you are using pure Bitcode code generation), it you should avoid raising an exception from any method that is not the entry point to the internal call.

It is recommended that if you need to raise an error condition from nested parts of your code, surface this error to the topmost method that is surfaced as an internal call and raise the exception there.

mono_raise_exception

mono_unhandled_exception

mono_print_unhandled_exception

Exception Types: General API

mono_exception_from_name_domain

mono_exception_from_name

mono_exception_from_name_msg

mono_exception_from_name_two_strings

Obtaining Common Exceptions

There are a number of common exceptions that are used by the runtime, use the routines in this section to get a copy of those exceptions.

mono_get_exception_appdomain_unloaded

mono_get_exception_argument

mono_get_exception_argument_null

mono_get_exception_argument_out_of_range

mono_get_exception_arithmetic

mono_get_exception_array_type_mismatch

mono_get_exception_bad_image_format

mono_get_exception_cannot_unload_appdomain

mono_get_exception_class

mono_get_exception_divide_by_zero

mono_get_exception_execution_engine

mono_get_exception_file_not_found2

mono_get_exception_file_not_found

mono_get_exception_index_out_of_range

mono_get_exception_invalid_cast

mono_get_exception_io

mono_get_exception_missing_method

mono_get_exception_not_implemented

mono_get_exception_null_reference

mono_get_exception_overflow

mono_get_exception_security

mono_get_exception_serialization

mono_get_exception_stack_overflow

mono_get_exception_synchronization_lock

mono_get_exception_thread_abort

mono_get_exception_thread_state

mono_get_exception_type_initialization

mono_get_exception_type_load

mono_get_exception_invalid_operation

mono_get_exception_missing_field

mono_get_exception_not_supported

mono_get_exception_reflection_type_load

mono_exception_from_token_two_strings

mono_get_exception_bad_image_format2

mono_get_exception_field_access

mono_get_exception_method_access

mono_get_exception_out_of_memory

mono_get_exception_runtime_wrapped

mono_get_exception_thread_interrupted