Closed shepmaster closed 3 years ago
Another problem I've got, from which this originated:
I was always using something like Err(MyError::ResponseLimit { ... })
. That works well untill you try to emit a leaf error including a backtrace. Then you need ResponseLimit { ... }
. But you can't do return Err(ResponseLimit { ... });
, because that's not a MyError
, it also won't work with return Err(MyError::ResponseLimit(ResponseLimit { ... }))
.
The fix is to use return ResponseLimit { ... }.fail();
and it works magically. I found that by accident browsing through the docs again.
Another problem I found while learning SNAFU is that https://github.com/shepmaster/snafu/blob/2c2e6ea5617be02c06e0a8144a5e391de8cd067e/src/guide/attributes.md#controlling-visibility was nowhere to be found in the main docs.
Everything clicked after I found this guide.
Using .into()
inside a context selector causes
cannot infer type for type parameter `__T0` declared on the struct ...
e.g.
Foo { message: "hello".into() }.fail()
A common error is attempting to use
MyErrorEnum::Variant
when the context selectorVariant
should be used instead. It's worth documenting this.Are there any other common issues?