Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.async by
The inner try exception handling clears the exception status of the outer try, making it return successfully instead of rethrowing.
In the following snippet, prn is executed althought it should be dead code.

(let [chan (a/chan)
      npe! nil]
    (try (npe!)
           (try (a/>! chan (npe!))
                (catch NullPointerException _))))
    (prn "this is fine.")))

4 Answers

0 votes

Comment made by: hiredman

if you could test this with the patch from ASYNC-198 applied that would be great

0 votes

Comment made by: leonoel

This patch doesn't fix the issue.
The problem with current design is that only one exception at a time can be stored (in the CURRENT-EXCEPTION slot) so when you have to deal with more than one the latest overwrite the previous.

0 votes

Comment made by: hiredman

is based on top of the patch for ASYNC-198

finallys can either be entered in the normal course of execution or
when handling an exception. so a finally X behaves sort of like

(try (let (link: r (code)) (X) r) (catch Throwable t (X) (throw t)))

previously the :try code was generating a single finally block which
tried to determine if it needed to rethrow an exception or not by
looking at the value of CURRENT-EXCEPTION, but this didn't work
correctly in certained nested try/catches.

so now the :try code generates two finally blocks, one that rethrows
and one that doesn't. the rethrow block goes on the exception frames
stack, and the not rethrowing block is jumped to at the end up the
body and each exception handler.

the patch also gets rid of CURRENT-EXCEPTION entirely, as it was only used by finally to determine if it needed to throw or not

0 votes
Reference: https://clojure.atlassian.net/browse/ASYNC-220 (reported by leonoel)