GithubHelp home page GithubHelp logo

Comments (5)

cramertj avatar cramertj commented on June 27, 2024 1

There's a context method on the Fail trait that you can use-- it calls Context::with_err internally.

from failure.

U007D avatar U007D commented on June 27, 2024

Thanks, @cramertj, I'll give that a shot.

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

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.

U007D avatar U007D commented on June 27, 2024

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.

U007D avatar U007D commented on June 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.