Coder Social home page Coder Social logo

Comments (3)

fralalonde avatar fralalonde commented on May 12, 2024

Since Dipstick itself doesnt return errors and only propagates the errors from other layers, just boxing them up seemed to be the simplest way, no failure crate / dependency required. Could just adding Send + Sync to the Boxed trait satisfy your requirements? What would be the gain in returning a concrete Dipstick Error struct? All it would do (for now) is wrap other errors...

from dipstick.

vorner avatar vorner commented on May 12, 2024

Send + Sync is a good start (things that are not are really hard to work with and mostly incompatible with any crate that helps with error handling). In the case of just propagating, it might be a good solution.

The advantage of an enum wrapper around concrete types are:

  • You can see in documentation what erros may happen.
  • All the Send, Sync and possibly other auto-traits are handled by the compiler.
  • It's a bit easier to handle some of the errors in a different way than the rest, by matching. You can still downcast the boxed ones, but that's a bit more work.

from dipstick.

fralalonde avatar fralalonde commented on May 12, 2024

I've made a PR to add Send + Sync to boxed errors.

For the record, I also I rewrote an Error enum, but pulled it back. Maintaining an Enum along with the required From impls is not something I want to commit to as it feels the whole Rust error management is still in shift anyway and a better way might yet come up. Also, it's not a showstopper, especially as the errors currently being reported are probably not rich enough to mandate handling them in a match. I understand your points though and will keep them in mind when it's time to revisit the error mechanism.

from dipstick.

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.