-
Notifications
You must be signed in to change notification settings - Fork 29
/
TryCatchFinally.scala
41 lines (39 loc) · 992 Bytes
/
TryCatchFinally.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.thoughtworks.dsl
package keywords
import Dsl.IsKeyword
import scala.util.control.Exception.Catcher
case class TryCatchFinally[+BlockKeyword, +CaseKeyword, +FinalizerKeyword](
block: () => BlockKeyword,
cases: Catcher[CaseKeyword],
finalizer: () => FinalizerKeyword
) extends Dsl.Keyword.Trait
object TryCatchFinally {
given [
Value,
OuterDomain,
BlockKeyword,
BlockDomain,
CaseKeyword,
FinalizerKeyword,
FinalizerDomain
](using
Dsl.Searching[TryFinally[
TryCatch[BlockKeyword, CaseKeyword],
FinalizerKeyword
], OuterDomain, Value]
): Dsl.Composed[TryCatchFinally[
BlockKeyword,
CaseKeyword,
FinalizerKeyword
], OuterDomain, Value] = Dsl.Composed {
case (
TryCatchFinally(
block,
catcher,
finalizer
),
handler
) =>
TryFinally(() => TryCatch(block, catcher), finalizer).cpsApply(handler)
}
}