logoalt Hacker News

skydhashlast Tuesday at 7:05 PM1 replyview on HN

It's all about designing software. The callee is the one encountering the error, not any of the caller up in the stack trace. Somewhere in the call chain, there's a need to take a decision.

So you, as the developer, decide where that needs to be. It may be at the callee level (like an exponential retry) or at the caller level (display an error message). In the later case, you may want to add more information to the error data block, so that the caller my handle the situation appropriately. So if you want tracing, you just need to wrap the error and returns it. Then your logging code have all the information it needs: like

  [error saving file [permission error [can't access file]]]
instead of just [syscall.EINVAL].

Replies

rollcatlast Tuesday at 7:41 PM

> So if you want tracing, you just need to wrap the error and returns it.

Here we go, fifth time we're both spelling this one out. This thread is now a meta-self-joke.