Skip to content

ExecutionContext.defaultReporter should try to use Thread.getDefaultUncaughtExceptionHandler if available #11535

Open
@dylemma

Description

@dylemma

From https://github.com/scala/scala/blob/2.13.x/src/library/scala/concurrent/ExecutionContext.scala#L221 I see that ExecutionContext's defaultReporter just does _.printStackTrace.

I found that the Monix library has a similar mechanism for its Scheduler concept, where the default error reporter tries to look up Thread.getDefaultUncaughtExceptionHandler before falling back to the old printStackTrace approach. See https://github.com/monix/monix/blob/v3.0.0-RC2/monix-execution/jvm/src/main/scala/monix/execution/internal/DefaultUncaughtExceptionReporter.scala#L28

I think this is desirable behavior for all in-JVM cases, since it allows you to set up logging or other custom error-handling side effects without having to resort to creating a custom ExecutionContext.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions