1 -{ extension 'trycatch' }
4 ----------------------------------------------------------------------
11 ----------------------------------------------------------------------
12 print "2) caught error"
16 printf(" Successfully caught %q", x)
20 ----------------------------------------------------------------------
21 print "3) no error, with a finally"
29 ----------------------------------------------------------------------
30 print "4) error, with a finally"
41 ----------------------------------------------------------------------
42 print "5) nested catchers"
46 catch "some_other_error" ->
47 assert (false, "mismatch, this must not happen")
49 catch "some_error"/x ->
50 printf(" Successfully caught %q across a try that didn't catch", x)
52 assert (false, "We shouldn't reach this catch-all")
56 ----------------------------------------------------------------------
57 print "6) nested catchers, with a 'finally in the inner one"
61 catch "some_other_error" ->
62 assert (false, "mismatch, this must not happen")
64 print " Leaving the inner try-catch"
66 catch "some_error"/x ->
67 printf(" Successfully caught %q across a try that didn't catch", x)
69 assert (false, "We shouldn't reach this catch-all")
73 ----------------------------------------------------------------------
74 print "7) 'finally' intercepts a return from a function"
79 assert (false, "I'll never go there")
81 assert (false, "No exception should be thrown")
83 print " I do the finally before leaving f()"
87 printf(" f returned %q", fr)
90 ----------------------------------------------------------------------