Installs an unhandled exception hook and returns an old hook, or
null if no user-defined hooks were previously set.
The hook is invoked whenever there is an uncaught exception reaching the boundaries of the Kotlin world,
main(), worker boundary, or when Objective-C to Kotlin call not marked with
@Throws throws an exception.
The hook is in full control of how to process an unhandled exception and proceed further. For hooks that terminate an application, it is recommended to use terminateWithUnhandledException to be consistent with a default behaviour when no hooks are set.
Set or default hook is also invoked by processUnhandledException. With the legacy MM the hook must be a frozen lambda so that it could be called from any thread/worker.