@@ -54,12 +54,12 @@ def supervisedError[E, F[_], T](em: ErrorMode[E, F])(f: OxError[E, F] ?=> F[T]):
54
54
// all forks are guaranteed to have finished; some might have ended up throwing exceptions (InterruptedException or
55
55
// others), but if the scope ended because of an application error, only that result will be returned, hence we have
56
56
// to add the other exceptions as suppressed
57
- if em.isError(scopeResult) then s.addExceptionsAsSuppressed (scopeResult, em) else scopeResult
57
+ if em.isError(scopeResult) then s.addSuppressedErrors (scopeResult, em) else scopeResult
58
58
catch
59
59
case e : Throwable =>
60
60
// all forks are guaranteed to have finished: some might have ended up throwing exceptions (InterruptedException or
61
61
// others), but only the first one is propagated below. That's why we add all the other exceptions as suppressed.
62
- s.addOtherExceptionsAsSuppressedTo (e)
62
+ s.addSuppressedErrors (e)
63
63
throw e
64
64
65
65
private [ox] sealed trait Supervisor [- E ]:
@@ -79,6 +79,7 @@ private[ox] class DefaultSupervisor[E] extends Supervisor[E]:
79
79
// the result might be completed with: a success marker, an app error, or an exception
80
80
private val result : CompletableFuture [ErrorModeSupervisorResult | E ] = new CompletableFuture ()
81
81
private val otherExceptions : java.util.Set [Throwable ] = ConcurrentHashMap .newKeySet()
82
+ private val otherErrors : java.util.Set [E ] = ConcurrentHashMap .newKeySet()
82
83
83
84
override def forkStarts (): Unit = running.incrementAndGet()
84
85
@@ -88,7 +89,7 @@ private[ox] class DefaultSupervisor[E] extends Supervisor[E]:
88
89
89
90
override def forkException (e : Throwable ): Unit = if ! result.completeExceptionally(e) then otherExceptions.add(e)
90
91
91
- override def forkAppError (e : E ): Unit = if ! result.complete(e) then otherExceptions .add(SecondaryApplicationError (e) )
92
+ override def forkAppError (e : E ): Unit = if ! result.complete(e) then otherErrors .add(e )
92
93
93
94
/** Wait until the count of all supervised, user forks that are running reaches 0, or until any supervised fork fails with an exception.
94
95
*
@@ -98,16 +99,16 @@ private[ox] class DefaultSupervisor[E] extends Supervisor[E]:
98
99
*/
99
100
def join (): ErrorModeSupervisorResult | E = unwrapExecutionException(result.get())
100
101
101
- def addOtherExceptionsAsSuppressedTo (e : Throwable ): Throwable =
102
+ def addSuppressedErrors (e : Throwable ): Throwable =
102
103
otherExceptions.forEach(e2 => if e != e2 then e.addSuppressed(e2))
104
+ otherErrors.forEach(e2 => e.addSuppressed(SecondaryApplicationError (e2)))
103
105
e
104
106
105
- def addExceptionsAsSuppressed [F [_], T ](r : F [T ], errorMode : ErrorMode [E , F ]): F [T ] =
107
+ def addSuppressedErrors [F [_], T ](r : F [T ], errorMode : ErrorMode [E , F ]): F [T ] =
106
108
var result = r
107
- otherExceptions.forEach(e => result = errorMode.addSuppressed(result, e))
109
+ otherExceptions.forEach(e => result = errorMode.addSuppressedException(result, e))
110
+ otherErrors.forEach(e => result = errorMode.addSuppressedError(result, e))
108
111
result
109
112
110
113
private [ox] enum ErrorModeSupervisorResult :
111
114
case Success
112
-
113
- case class SecondaryApplicationError [E ](e : E ) extends Throwable (" Secondary application error reported to the supervisor" )
0 commit comments