Open Mirko-von-Leipzig opened 2 months ago
Common suggestion is to prefer
anyhow
for errors in an application as usually we don't care about the what, only that an error happened. For libs insteadthiserror
/structure errors are suggested but these are just guidelines.
I think this is roughly how things work now, no? Basically, we use thiserror
in the libs and use anyhow
in the miden-node
binary.
I think this is roughly how things work now, no? Basically, we use
thiserror
in the libs and useanyhow
in themiden-node
binary.
Correct; however these are just rough rules of thumb. The more accurate gauge is whether one cares about the error variants at all. Or put slightly differently - are our rpc
, store
and block-producer
crates libraries, or are they just components on the node
binary split into separate crates for organization/decoupling purposes?
Semantic games aside though, we just need to ensure that we don't lose any important context along the way. Something like anyhow
makes that easier, but this is of course just as possible with thiserror
or the other error types - just a bit more effort and care required. Though one does lose line info which could be helpful in logs.
Hmm now that I've logged on to the actual instance, the logs provided initially seem to be truncated.
Error: Failed to serve store: initialisation of the Api has failed: Genesis block error: Failed to read genesis file "./genesis.dat": No such file or directory (os error 2)
On site logs appear to be fine ito context so maybe this is a non-issue. Could be worth taking a look regardless.
Related to #499.
As evidenced in #483, our logs are missing useful context.
A lot of this context is going missing because we are using structured error enums which aren't encapsulating the inner error.
Common suggestion is to prefer
anyhow
for errors in an application as usually we don't care about the what, only that an error happened. For libs insteadthiserror
/structure errors are suggested but these are just guidelines.In general, we should use
anyhow
if we don't care to match on the exact error variant.