3 ms·
This annoyed me to no end working in node.js, having to manually re-raise errors at every step is pretty tiresome and error prone (no pun intended).
by wcummings 11y ago
This annoyed me to no end working in node.js, having to manually re-raise errors at every step is pretty tiresome and error prone (no pun intended).
- vendakka 11y agoI've recently started working in node after spending some time in Go-land and the reverse applies to me. The code I'm writing is a mix of js + Go and I find that in JS I have no sense for what can go wrong since it's not obvious to me if a method will throw an exception or not. However, with Go it forces me to think about my error path. I do find littering code with err checks can be annoying and ended up reaching a compromise. For all code that is likely to be part of an externally public package I use 'if err !=' checks. For application level code that will be internal to my application (and internal to the file I'm working in) I use a small library [1] I wrote, that uses the panic-defer-recover style talked about in the Go documents for internal error handling [2]. However, I find that in most situations I usually prefer to not use panic-defer-recover, with if checks providing more clarity. [1] https://github.com/surullabs/fault https://github.com/surullabs/fault [2] http://golang.org/doc/effective_go.html#recover http://golang.org/doc/effective_go.html#recover