GithubHelp home page GithubHelp logo

Comments (6)

Yamakaky avatar Yamakaky commented on July 25, 2024

Something like https://play.rust-lang.org/?gist=f98139dcdd16cceb898731f0fe649a34&version=stable&backtrace=0?

from error-chain.

joshtriplett avatar joshtriplett commented on July 25, 2024

Wrapping the whole thing in a macro (which expects a closure as an argument) seems a little too magic to me. I'd prefer a helper like the toplevel_unwrap() I suggested above, or at most, a macro that takes a function name (chain_main!(real_main);).

Then again, I suppose you could pass a function name instead of a closure, so sure. But I'd still like the helper function version as well. And both the helper function and the macro should print the causes and possible backtrace, as shown in that blog entry.

from error-chain.

Yamakaky avatar Yamakaky commented on July 25, 2024

Yeah, it's just that I was on play.rust-lang.org, which doesn't allow the use of other crates.
How would you implement it? A trait on Result?

from error-chain.

joshtriplett avatar joshtriplett commented on July 25, 2024

Right. error-chain already provides a trait on Result, so this would just add one method to it.

from error-chain.

Yamakaky avatar Yamakaky commented on July 25, 2024

In fact, not exactly: ResultExt is defined on Result<T, E> where E: Error, and not E: ChainedError.

from error-chain.

joshtriplett avatar joshtriplett commented on July 25, 2024

Good point; in the absence of some kind of specialization, that trait wouldn't work. But another trait could.

from error-chain.

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.