snafu icon indicating copy to clipboard operation
snafu copied to clipboard

Support AsErrorSource for error sources that don't implement std::error::Error

Open iliana opened this issue 6 years ago • 3 comments

Since starting to use SNAFU I've repeatedly run into libraries whose error types implement Debug + Display but not std::error::Error.

Two options I can think of that might make this easier to deal with for users:

  • failure has a Compat struct which can just wrap the type, and implements Error if the underlying type implements Debug + Display. (I've been writing types like this as a workaround in my projects.)
  • Add implementations of AsErrorSource for dyn Debug + Display + 'static, etc.

iliana avatar Jul 01 '19 20:07 iliana

Hmm. This feels like it could be similar to #99, another place where AsErrorSource isn’t valid (due to ’static).

There, I proposed being able to effectively disable the Error::source method, which should also allow this case to work.

Can you see any downsides to disabling it in your cases?

shepmaster avatar Jul 03 '19 13:07 shepmaster

I think that sounds like it could work, yes. I don't see any downsides for my particular use cases.

iliana avatar Jul 03 '19 17:07 iliana

See also #23

shepmaster avatar May 15 '20 13:05 shepmaster