Documentation

logUnhandledException

logUnhandledException()

(error: any): void

Log given error and emit an event on the UnhandledErrorEmitter instance.

This function is particularly helpful to catch exceptions that are thrown by asynchronous functions, in a synchronous context.

Example

import { logUnhandledException } from "typescene";
myActivity.activateAsync().catch(logUnhandledException);

Handling errors

To handle errors in some other way (other than logging to the console), observe events on the singleton UnhandledErrorEmitter instance.

UnhandledErrorEmitter.observe(class {
  onEvent(e: UnhandledErrorEvent) {
    if (e.error) {
      // ... (do something with the error, e.g.
      // send to reporting service back end)
    }
  }
})