If you are interested in learning why check-handle differs from traditional exception handling, you can read https://go.googlesource.com/proposal/+/master/design/go2draf....
If you just feel like snarking, then sorry for spoiling.
If you just feel like snarking, then sorry for spoiling.
And to work around that problem, you need some kind of generics that lets you define error signatures in terms of other signatures - e.g. for map(), you want to say that it can return an error if and only if the function it maps can return an error (and ditto for error types).
handle err {
cleanup1()
return 42, nil
}
handle err {
cleanup2()
}
check dostuff()
into try {
try {
dostuff();
} catch (Exception e) {
cleanup2();
throw e;
}
} catch (Exception e) {
cleanup1();
return 42;
}