From ce63ddfe547b7631c787e107a6b07f0d00672210 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Jan 2022 16:54:36 +0530 Subject: [PATCH] macOS: Print out unhandled exceptions --- kitty/cocoa_window.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index 19e768056..5a2d58527 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -861,10 +861,17 @@ - (BOOL)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type { {NULL, NULL, 0, NULL} /* Sentinel */ }; +static void +uncaughtExceptionHandler(NSException *exception) { + log_error("Unhandled exception in Cocoa: %s", [[exception description] UTF8String]); + log_error("Stack trace:\n%s", [[exception.callStackSymbols description] UTF8String]); +} + bool init_cocoa(PyObject *module) { memset(&global_shortcuts, 0, sizeof(global_shortcuts)); if (PyModule_AddFunctions(module, module_methods) != 0) return false; register_at_exit_cleanup_func(COCOA_CLEANUP_FUNC, cleanup); + NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); return true; }