Description
Both implementations call console.error
and pass exception.toString()
, which is basically a name of Exception class + message. In addition, console.error
prints a stack trace from a call site (not from the exception!!), which users often consider a stack trace from the exception (example).
In this project, you can find a project with a simple repro and possible improvements implemented via CoroutineExceptionHandler
.
I think #1
or any other way to rethrow the exception is the best option since there are standard ways inside JS runtimes to process unhandled exceptions. These might be used directly or by some library intended to handle problems on a page. In the worst case, a browser (runtime) will show the error in a standard and more convenient way.