Comments (5)
There's a context method on the Fail
trait that you can use-- it calls Context::with_err
internally.
from failure.
Thanks, @cramertj, I'll give that a shot.
from failure.
Yep, the intent is you create a context with Fail::context
or (if you want to create one without an underlying error) with Context::new
. Context::with_err
is an implementation detail.
from failure.
I guess I'm confused. In impl From... for Error
above, I am wrapping a foreign error (which is not Fail
);
I don't know how can I initialize Error::inner
using Fail::context()
, without a Fail
instance available. Any ideas?
I'm also a bit puzzled on the asymmetry between using Fail::context
for context with underlying error and Context::new
for context without underlying error. I've no doubt there are valid implementation reasons for the split, but I wonder if the ergonomics could be improved by supporting both scenarios under Fail
with Fail::context
for context without an underlying error and Fail::context_err
for context with an underlying error (or something similar). Thoughts?
from failure.
Ah, nvm. I see now that Fail::context is supposed to be used in error's throw path, rather than at its declaration point. That clears up my confusion.
from failure.
Related Issues (20)
- Addition of name member to Fail trait is a semver-breaking change HOT 4
- Should `backtrace` dependency be optional? HOT 1
- Compat should override method source() HOT 1
- Repository field for `failure_derive` and `failure` do not match HOT 1
- Support for an alloc feature? HOT 1
- failure-v0.1.5 fails to compile with rustc-1.37.0 HOT 6
- Add option to derive Debug identical to Display HOT 1
- Collaborate on a "core::Error" crate with snafu, anyhow and other error crates HOT 1
- Update failure_derive dependencies HOT 1
- support `at` method using for locate error
- Move Repository To rust-lang HOT 7
- Fix guide example code
- Memory safe violation by abusing `__private_get_type_id__` HOT 1
- Propagate never type
- error: /lib64/libc.so.6: version `GLIBC_2.18' not found HOT 2
- 'backtrace' is forcing an increased MinSRV; pin 'backtrace' to `version = "<= 0.3.30"` HOT 6
- [FEATURE REQUEST] Add ability to `bail!` and `ensure!` error types.
- failure_derive won't build with quote 1.0.3 HOT 16
- Why does this exist? HOT 2
- "trailing semicolons in expression macro bodies" breaks with bail
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from failure.