From
http://www.eros-os.org/pipermail/e-lang/2004-April/009810.html
:
? try { throw("oops") } catch ==1 {}
# problem: oops
? try { throw("oops") } catch ==1 {} catch ==2 {}
# problem: no match: problem: oops
The expansion for multiple-catch-clause try-catch does
not follow the
semantics of the kernel try-catch when the pattern
match fails - it
creates a new exception instead of simply passing
on/rethrowing the
unmatched one.
This will be important once E has a useful exception
type system (which
I am working on a proposal for).
(A similar problem exists with matchers in object
definitions, with the
additional complication that even in Kernel-E,
matcher-with-failing-pattern is not the same as
no-matcher. This is why
help(require) doesn't work.)
? e`try {} catch a {} catch b {}`
# value: e`try {
# null
# } catch specimen_1 {
# if (specimen_1 =~ a) {
# null
# } else {
# if (specimen_1 =~ b) {
# null
# } else {
# throw.run("no match: ".add(specimen_1))
# }
# }
# }`
Possible solutions:
1. Replace e`throw("no match: " + @x)` with
e`throw($x)`, though there
will still be an extra throw() in the stack trace.
2. Allow an arbitrary number of catch clauses in Kernel-E.
3. Somehow make match failure of all of the individual
patterns in the
expansion cause failure of the try-catch expression's
pattern.
4. Expand each catch clause into a nested try-catch.
Logged In: YES
user_id=54168
Just noting that the "similar problem exists with matchers
in object
definitions"
http://sourceforge.net/tracker/index.php?func=detail&aid=1211088&group_id=75274&atid=551529
has now been fixed