logoalt Hacker News

osiris88yesterday at 9:21 PM1 replyview on HN

By error accumulation, I mean a tree of errors, not a simple chain. The chain is only useful at the very lowest level.

The tree allows you to say e.g. this function failed because n distinct preconditions failed, all of which are interesting, and might have lower level details. Or, I tried to do X which failed, and the fallback also failed. The error chain thing doesn’t capture either of these semantics properly.

Check out `rootcause` which is the first one I’ve seen to actually try to do this.

I’ll respond to the backtrace comments shortly.


Replies

burntsushiyesterday at 9:26 PM

I don't see any reason for something like `rootcause` to become foundational. Most errors are a linear chain and that's good enough for most use cases.

It's correct to say that `std::error::Error` does not support a tree of errors. But it is incorrect to say what you said: that it's pointless and doesn't allow error accumulation. It's not pointless and it does provide error accumulation. Saying it doesn't is a broad overstatement when what you actually mean is something more precise, narrow and niche.

show 1 reply