In api.js, you bind an uncaught exception handler. Not only is this bad practice for a library, it forces an exit, and with a successful error code which is even worse. This kind of handler should always be in the top level application, and it should certainly not override the behavior of what a parent application might specify. Fatally, it just silently exits the program if you don't know about or bind the event yourself, nor does it pass along the error object as-is. So many problems for a few lines of code!
In api.js, you bind an uncaught exception handler. Not only is this bad practice for a library, it forces an exit, and with a successful error code which is even worse. This kind of handler should always be in the top level application, and it should certainly not override the behavior of what a parent application might specify. Fatally, it just silently exits the program if you don't know about or bind the event yourself, nor does it pass along the error object as-is. So many problems for a few lines of code!