diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-24 23:13:24 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-24 23:19:15 +0200 |
commit | 513cc78f85d8c45a9492ae25034cd2357714cfdf (patch) | |
tree | 4fba743dbb50d9ef38b5c2178b4a11757d9e54d4 /modules/mono/mono_gd/gd_mono.h | |
parent | adae2b073811d0f81afdfab277fdb27d2ba9f16a (diff) | |
download | redot-engine-513cc78f85d8c45a9492ae25034cd2357714cfdf.tar.gz |
Mono: Add option to keep running after unhandled exceptions
By default, an unhandled exception will cause the application to be terminated; but the project setting `mono/unhandled_exception_policy` was added to change this behaviour.
The editor is hard-coded to never terminate because of unhandled exceptions, as that would make writing editor plugins a painful task, and we cannot kill the editor because of a mistake in a thirdparty plugin.
Diffstat (limited to 'modules/mono/mono_gd/gd_mono.h')
-rw-r--r-- | modules/mono/mono_gd/gd_mono.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index deebe5fd50..c5bcce4fa1 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -80,6 +80,13 @@ String to_string(Type p_type); class GDMono { +public: + enum UnhandledExceptionPolicy { + POLICY_TERMINATE_APP, + POLICY_LOG_ERROR + }; + +private: bool runtime_initialized; bool finalizing_scripts_domain; @@ -102,6 +109,8 @@ class GDMono { HashMap<uint32_t, HashMap<String, GDMonoAssembly *> > assemblies; + UnhandledExceptionPolicy unhandled_exception_policy; + void _domain_assemblies_cleanup(uint32_t p_domain_id); bool _are_api_assemblies_out_of_sync(); @@ -162,7 +171,9 @@ public: static GDMono *get_singleton() { return singleton; } - static void unhandled_exception_hook(MonoObject *p_exc, void *p_user_data); + GD_NORETURN static void unhandled_exception_hook(MonoObject *p_exc, void *p_user_data); + + UnhandledExceptionPolicy get_unhandled_exception_policy() const { return unhandled_exception_policy; } // Do not use these, unless you know what you're doing void add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly); |