File tree 1 file changed +4
-3
lines changed
src/main/scala/org/learningconcurrency/exercises/ch4
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,9 @@ object Ex2 extends App {
28
28
29
29
val p = Promise [T ]
30
30
31
- def apply (): T = if (p.isCompleted) Await .result(p.future, Duration .Inf )
32
- else throw new Exception (" Not contain a value" )
31
+ def apply (): T =
32
+ if (p.isCompleted) Await .result(p.future, Duration .Inf )
33
+ else throw new Exception (" Not contain a value" )
33
34
34
35
def := (x : T ): Unit = if (! p.tryComplete(Try (x))) throw new Exception (" Value is already assigned" )
35
36
}
@@ -41,7 +42,7 @@ object Ex2 extends App {
41
42
try {
42
43
v := s " v = ${Thread .currentThread().getName}"
43
44
} catch {
44
- case e => log(s " Error !!! ${e.getMessage}. Current value = ${v.apply}" )
45
+ case e: Throwable => log(s " Error !!! ${e.getMessage}. Current value = ${v.apply}" )
45
46
}
46
47
}
47
48
)
You can’t perform that action at this time.
0 commit comments