Catching thread exception

Who should catch the exception? Detached threads are really that: they are no longer supervised by anything. They die without leaving a trace as they have no place to report to. Mostly for debugging it prints exceptions or failure. If you do not want that, wrap the goal in catch/3 and send the exception somewhere. Note that applications can use prolog_listen/3 to keep overall track of created and terminated threads. Not sure how useful that is.

P.s. Possibly you think a dying thread should cause an asynchronous exception in the thread that created the thread? Note that in the POSIX thread world the creator is irrelevant and may decide to terminate before its children (that notion doesn’t exist anyway).

1 Like