linuxmint/cjs

Better Exception handling

Closed this issue · 3 comments

I don't really know how cjs / gjs works, so this could be total wrong.
The fact is: unless I use a try - catch statement a exception can break whole cinnamon. I think it is really unnecessary and kind of annoying to always write

try {
    ...
catch(e){
    global.logError(e);
}

I mean, what should I else use instead of using global.logError?

Short Conclusion

I want that every exception is logged without needing a try-catch statement; for minor Exceptions maybe only a warning.

It's quite common that exceptions terminate a program if there is no try/catch. Many programming languages work this way. (A notable exception is C, which doesn't know try/catch and exceptions)

Yes, that a program (or xlet) breaks is also the case when using try catch, but in a lower level.
E.g. the applet fails. but not Cinnamon.


My main problem with cjs / Cinnamon error handling is that the logging is happening at two levels: lg for caught and processed and xsession-errors for uncaught.
Imo, It's easier if all exceptions are logged into lg. (more similar to web js)

For applets & xlets it's actually not a bad idea to catch errors from them and show a message that Applet X has crashed. I think that's separate from the question where to log errors. If we have a global function for logging then you can expect that to log at the right place.