iroha
iroha copied to clipboard
Error messages in `no_std` are useless
Due to usage of
-
#[cfg_attr(feature = "std", derive(thiserror::Error))]
and -
#[cfg_attr(feature = "std", source)]
We lose a lof of info about errors. Because of that Debug
print of, for example, ValidationFail
error may look just like Instruction execution failed
without additional info (while still containing this information in the type).
I suggest to keep the idea of source
because it gives us good printing in std
. But we need to fix no_std
too.
Solutions I see:
- Use thiserror-core -- fork of
thiserror
which supportsno_std
. There is a PR implementing this feature inthiserror
, butthiserror
maintainer seems to completely ignore it - Feature-gated
display
impls. Right now we just write something like#[display(fmt = "Query execution failed")]
which could be refactored as:
#[cfg_attr(feature = "std", display(fmt = "Query execution failed"))]
#[cfg_attr(not(feature = "std"), display(fmt = "Query execution failed: {0}"))]