Skip to content

Commit

Permalink
Remove throwableContinuationDsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry committed Dec 26, 2021
1 parent 9f6c7fd commit c6676ea
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions Dsl/src/main/scala/com/thoughtworks/dsl/Dsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,6 @@ private[dsl] trait LowPriorityDsl0 extends LowPriorityDsl1 { this: Dsl.type =>
// }
// }

private def throwableContinuationDsl[Keyword, LeftDomain, Value](implicit
restDsl: Dsl.Searching[Keyword, LeftDomain, Value]
): Dsl[Keyword, LeftDomain !! Throwable, Value] = Dsl {
(keyword, handler) => continue =>
restDsl(
keyword,
// Use `new` to support the `return`
new (Value => LeftDomain) {
def apply(value: Value): LeftDomain = {
val protectedContinuation =
try {
handler(value)
} catch {
case NonFatal(e) =>
return continue(e)
}
// FIXME: Shift[Domain, Throwable]
protectedContinuation(continue)
}
}
)
}
given [Keyword, LeftDomain, Value](using
Dsl.IsStackSafe[LeftDomain],
Dsl.Searching[Keyword, LeftDomain, Value]
): Dsl.Derived.StackSafe[Keyword, LeftDomain !! Throwable, Value] =
Dsl.Derived.StackSafe(throwableContinuationDsl)
given [Keyword, LeftDomain, Value](using
util.NotGiven[Dsl.IsStackSafe[LeftDomain]],
Dsl.Searching[Keyword, LeftDomain, Value]
): Dsl.Derived.StackUnsafe[Keyword, LeftDomain !! Throwable, Value] =
Dsl.Derived.StackUnsafe(throwableContinuationDsl)

}

object Dsl extends LowPriorityDsl0 {
Expand Down

0 comments on commit c6676ea

Please sign in to comment.