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; }