summaryrefslogtreecommitdiff
path: root/modules/mono/mono_gd/gd_mono.cpp
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2017-10-23 00:35:04 +0200
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2017-10-23 00:35:14 +0200
commit45e5e23ee83d202461f1753b1d94afc51d3a5aa1 (patch)
tree513bd0522d4207236af464919c342fb3aa163c74 /modules/mono/mono_gd/gd_mono.cpp
parentacaaf2e440994bf99b9dcf1ba14ab4a7aa9be854 (diff)
Mono: Prevent raising exceptions in native code
For now we will just print the exceptions we catch. Later, we should use something similar to 'mono_set_pending_exception(ex)'.
Diffstat (limited to 'modules/mono/mono_gd/gd_mono.cpp')
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index d7aedbbcf0..4b5f5eb137 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "gd_mono.h"
+#include <mono/metadata/exception.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-gc.h>
@@ -47,6 +48,15 @@
#include "../editor/godotsharp_editor.h"
#endif
+void gdmono_unhandled_exception_hook(MonoObject *exc, void *user_data) {
+
+ (void)user_data; // UNUSED
+
+ ERR_PRINT(GDMonoUtils::get_exception_name_and_message(exc).utf8());
+ mono_print_unhandled_exception(exc);
+ abort();
+}
+
#ifdef MONO_PRINT_HANDLER_ENABLED
void gdmono_MonoPrintCallback(const char *string, mono_bool is_stdout) {
@@ -214,6 +224,8 @@ void GDMono::initialize() {
// The following assemblies are not required at initialization
_load_all_script_assemblies();
+ mono_install_unhandled_exception_hook(gdmono_unhandled_exception_hook, NULL);
+
OS::get_singleton()->print("Mono: ALL IS GOOD\n");
}