Skip to content

Commit c664d7f

Browse files
authored
Better error message when attempting to create a fork outside of a scope (#354)
1 parent ba1eaed commit c664d7f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/scala/ox/internal/ThreadHerd.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ private[ox] class ThreadHerd(threadFactory: ThreadFactory):
8888

8989
currentScope.get() match
9090
case null =>
91-
throw new IllegalStateException("Forks can only be started inside a concurrency scope, or from other forks started in the scope.")
91+
throw new IllegalStateException(
92+
"Forks can only be started inside a running concurrency scope, or from other forks started in the scope. " +
93+
s"Creating this fork was attempted from an unrelated thread: ${Thread.currentThread.getName}."
94+
)
9295
case scope => doAssert(scope)
96+
end match
9397
end verifyCurrentThreadInScopeTree
9498

9599
private def assertOnOwnerThread(): Unit =

0 commit comments

Comments
 (0)