-
Notifications
You must be signed in to change notification settings - Fork 982
Description
Currently downstream errors containing Db::Error have to add manual bounds for Debug if they want any printing strategy. However, Debug is derived or impld for all current errors used in revm. This would be a breaking change, however it is unlikely that any downstream implementors have non-Debug error types (I checked the foundry fork DB and they're already Debug)
This affects EVMError<Db::Error> because it derives Debug and therefore has no Debug impl unless the inner Db::Error has a Debug bound
affected traits:
DatabaseDatabaseRefStateStateRefBlockHashBlockHashRef
What I want to do:
// broken code
#[derive(Debug, thiserror::Error)]
pub enum Error<Db>
where
Db: Database
{
// results in an error
// `EvmError<Db::Error>` cannot be formatted using `{:?}` because it doesn't implement `Debug`
#[error("{0:?}"]
Evm(EVMError<Db::Error>),
...
}
What I have to do instead:
#[derive(Debug, thiserror::Error)]
pub enum Error<Db>
where
Db: Database
// this bound holds for all current Database implementors, but must be manually written by consumers
Db::Error: Debug,
{
#[error("{0:?}"]
Evm(EVMError<Db::Error>),
...
}
the same is true of std::error::Error, however:
- this approach does not dovetail with the crates
extern crate alloc as stdstrategy forno_stdsupport - it would require an intermediary
trait ErrBoundto handle changing the bound for std/no_std - there would need to be a
cfg(feature = "std")implementation ofstd::error::ErrorforDatabaseComponentError
so while adding a std::error::Error it seems like supporting a bound of std::error::Error would be much more invasive, while adding Debug is non-invasive