Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Exceptions are interesting. The calls are asynchronous so you can't wrap the whole macro in a single try/catch. See node's wiki for an explanation on why this is a problem:

https://github.com/joyent/node/wiki/Async-exception-handling

Node encourages people to create functions like:

    function(err, x) {
        if(err) handle(err);
    }
This way they avoid the whole async + try/catch problem. It should be possible to define a macro that does something similar.

Avoiding that trap, individual try/catch statements still work fine:

    (timeout/timeout-macro
     (pn "Hello")
     (try*
      (pn (throw "Throwing up"))
      (catch e (pn (str "There was an error: " e))))
     (pn "World"))


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: