3 ms·
> It also may possibly make sense to log additional information available in local scope and throw the error up the stack. Like, time. This is why I often do "
by TeMPOraL 5y ago
> It also may possibly make sense to log additional information available in local scope and throw the error up the stack.
Like, time. This is why I often do "log and throw" or "log unexpected value and return it", depending on whether the code is exception-oriented or uses sum types instead. It's because time is an important piece of information to encode in an error log. When your error is caused by an external resource (e.g. RPC failure), you want to log it immediately to later be able to correlate it with external resource's logs or some other monitoring. If you don't the error may take some time to reach its final logging place - or, it may never reach it at all, if the application crashes in the meantime.