Giter Site home page Giter Site logo

Comments (5)

joachimvh avatar joachimvh commented on June 2, 2024 1

That would then have to be a dependency for most classes though.

The other option is going to non-Http errors as was already suggested before and have a handler somewhere at the end that converts them to status codes (probably called by the responseWriter). And if new errors are introduced they would require also making a new handler for them (which can be combined in a CompositeHandler as usual then).

Both of these do make #23 a bit harder to solve I think :D

from communitysolidserver.

RubenVerborgh avatar RubenVerborgh commented on June 2, 2024 1

A factory is a definitely viable avenue indeed; it does feel a bit heavy to always have this injected (given how common errors are).

That would make me lean towards a more adapter-like solution, where (for instance) the back-end layer throws a simple "Not Found" / "Not Exists" error, which is a data object that is later translated into the right HTTP error. So basically, factory strategy, but the factory takes in data objects such that not all classes need this factory.

from communitysolidserver.

RubenVerborgh avatar RubenVerborgh commented on June 2, 2024

We need to fix this. When reviewing #52, I see Http pop up everywhere because of this choice, and that feels very wrong, as this layer is HTTP-independent.

from communitysolidserver.

rubensworks avatar rubensworks commented on June 2, 2024

Maybe we want to make use of the factory pattern here, where we have an ErrorFactory that can be called to constructor errors of different types (that we define). During dependency injection, we could pass an HttpErrorFactory that would create HTTP-specific errors for our internal error types.

This would allows us to create other error factories later on, such as IpfsErrorfactory.

from communitysolidserver.

RubenVerborgh avatar RubenVerborgh commented on June 2, 2024

We have nice HTML errors now; I think that's enough.

from communitysolidserver.

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.