Git Product home page Git Product logo

Comments (6)

gregwebs avatar gregwebs commented on June 21, 2024

Oh, so the extra 400 response is related to using a browser for an API that wants to give a JSON response. Still doesn't make a lot of sense to me though.

from goliath.

dj2 avatar dj2 commented on June 21, 2024

If the browser is chrome, the second request is for favicon.ico usually.

from goliath.

dj2 avatar dj2 commented on June 21, 2024

Exceptions are caught and handled by the API. The problem being, if you throw an exception inside the API it will end up in no-where land unless it's caught. The middlewares would have already returned at that point and the ASYNC_CALLBACK has to be used. So, we catch the exception, turn it into a 400 response, and fire the ASYNC_CALLBACKS.

We could possibly also stuff the exception into rack.exception so you can still access it if desired. Then, if you want, you can change the response in your async middleware for exceptions.

Would that work for you?

from goliath.

gregwebs avatar gregwebs commented on June 21, 2024

Yes, I need access to the original exception, so rack.exception would be good. The other issue is the use of a 400 error code, which indicates a client error. In this case it should be a 500.

from goliath.

dj2 avatar dj2 commented on June 21, 2024

K, feel free to move it to a 500 from a 400 and add in rack.exception.

from goliath.

gregwebs avatar gregwebs commented on June 21, 2024

pull request in #51

from goliath.

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.