Giter VIP home page Giter VIP logo

Comments (7)

robinjoseph08 avatar robinjoseph08 commented on June 17, 2024

Hey @FabioFleitas thanks for looking into this. I think this is solid way to handle this case. It's a unique situation because when a 504 occurs, the response returned is empty, so I'm curious to see what value resp.content has. Is it empty as well or is it the status message of Gateway Timeout.

If you submit a PR for it, we'll gladly merge it in!

from lob-python.

FabioFleitas avatar FabioFleitas commented on June 17, 2024

You're right, it seems like the response returned is an empty string. Perhaps we could modify it to be:

if resp.status_code == 504:
    raise error.APIConnectionError(resp.content or 'Gateway Timeout',
        resp.content, resp.status_code, resp)

In the chance that resp.content is an empty string?

from lob-python.

robinjoseph08 avatar robinjoseph08 commented on June 17, 2024

Hmm... Try seeing if there's any content in resp.reason. That might have the more generic message that is mapped to the status code.

from lob-python.

FabioFleitas avatar FabioFleitas commented on June 17, 2024

Unfortunately our logs didn't save the resp.reason so not sure how I could go about testing to see what it says.

from lob-python.

FabioFleitas avatar FabioFleitas commented on June 17, 2024

Perhaps we go with error_msg = resp.content or resp.reason or 'Gateway Timeout' if we're unsure?

from lob-python.

robinjoseph08 avatar robinjoseph08 commented on June 17, 2024

I just quickly tested it using http://httpstat.us/504 and this:

print resp.status_code
if resp.status_code == 504:
    print resp.reason

printed this:

504
Gateway Timeout

So I think relying on resp.reason is a safe bet 👍

from lob-python.

FabioFleitas avatar FabioFleitas commented on June 17, 2024

Alright, let's do resp.content or resp.reason in case later down the road there is something in content? I noticed for example that http://httpstat.us/504 had "504 Gateway Timeout" as the content.

from lob-python.

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.