Global error catching?

Skip to first unread message

Michael Bach

Nov 5, 2020, 3:05:43 AM11/5/20
to Cappuccino & Objective-J

Dear Cappuccinorites:
I just had the situation that my application silently crashed in the browser, when the user did something I had not tested :) here:
Silent crash meant for the user that the app just became unresponsive. In the console, of course, the crash was obvious.
Question: How do I install something like a global try block around everything, which would allow me to at least put up a pertinent dialog box?
Thanks for your help, best, Michael

Mike Holman

Nov 5, 2020, 4:58:39 AM11/5/20
There used to be a port of UKCrashReporter from Cocoa:

I don’t know if it’s still functional but the code may be a useful starting point.


Sent from my iPhone

On 5 Nov 2020, at 08:05, Michael Bach <> wrote:

You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Keary Suska

Nov 5, 2020, 9:12:54 AM11/5/20
I install a global exception handler in -applicationWillFinishLaunching. Here is my implementation:

window.addEventListener('error', function (e) {
var userInfo = @{
CPLocalizedDescriptionKey: "Sorry, but a run-time error occurred. Please take a moment to report the error.",
CPLocalizedFailureReasonErrorKey: "Your browser window will be reloaded to clear the error or CERTS may not operate correctly.",
CPLocalizedRecoverySuggestionErrorKey: LMS_REPORT_ERROR_ACTION,
// recovery should reload browser to clear errors
CPRecoveryAttempterErrorKey: function () { window.location.reload(false); }
var error = [CPError errorWithDomain:CPCappuccinoErrorDomain code:LMS_RUNTIME_ERROR userInfo:userInfo];
[self presentError:error];

It used to catch every exception, sometimes even exceptions caused by browser plugins under Chrome. Recently, however, it doesn’t work as reliably as it used to, at least under Chrome, and I don’t recall when that began. Perhaps because the framework is overriding the global handler under certain situations. That may be why the LPCrashReporter author(s) hack the objj_msgSend implementation.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

Prof. Michael Bach

Nov 5, 2020, 12:51:00 PM11/5/20
to Keary Suska, Mike Holman,
Dear Keary & Mike:

Thank you very much for providing help, pointers and code! I have now implemented and even easier version (better than nothing :) and installed it in »applicationDidFinishLaunching«.

For what it’s worth, here my simple code:
window.addEventListener('error', function (e) {
alert("An error occured, I'm sorry. Error message:\r\r" + e.message + "\r\rIf it recurs, please notify, ideally relating the message, e.g. via a screeshot.\rI will look into it and endeavour to provide a fix.\r\rOn “Close”, the window will reload and you can retry.");

Thanks & best, Michael
Prof. Michael Bach <>

Reply all
Reply to author
0 new messages