tryCatch

Helper for wrapping external function calls in order to redirect any uncaught exceptions.

For example, when notifying attached TorEvent.Observer and one does not properly handle its exceptions, instead of it causing the entire program to crash, an UncaughtException is redirected to Handler.

NOTE: If Handler is null, block is still invoked and the UncaughtException is thrown.

Parameters

context

Contextual information about where/what block is to include in the UncaughtException

block

the thing to do that may or may not throw exception.

See also

io.matthewnelson.kmp.tor.runtime.RuntimeEvent.ERROR

Throws

if handler is null or Handler.invoke is set up to throw the exception