Git Product home page Git Product logo

Comments (6)

jsha avatar jsha commented on August 27, 2024

Thanks for the report! It looks like this is probably a difference between what happens when there's a timeout receiving headers vs a timeout reading the body. into_json maps all errors from serde_json::from_reader into InvalidData. I think the right solution here is to only map errors that are not already an IoError, and pass through IoErrors unchanged.

from ureq.

kangalio avatar kangalio commented on August 27, 2024

I will try to make a pull request

from ureq.

kangalio avatar kangalio commented on August 27, 2024

I think the right solution here is to only map errors that are not already an IoError, and pass through IoErrors unchanged.

As far as I can tell, there's no way to know the underlying error type in a serde_json::Error. Looking at its docs it doesn't expose any functions that would allow us to extract a std::io::Error.

I don't even know if the "timed out reading response" error message is actually a std::io::Error or serde_json's own error - its API doesn't expose this information.

The best workaround I can think of is to format the serde_json::Error into a string and return IoError::TimedOut if the error message equals "timed out reading response".

from ureq.

algesten avatar algesten commented on August 27, 2024

@kangalioo Thanks for looking into this. I think it should be possible to get out the original io::Error

First we have is_io, which isn't strictly needed.

Then we have source by virtue of serde_json::Error implementing std::error::Error.

And finally we have downcast_ref to get the ref to the io::Error.

from ureq.

kangalio avatar kangalio commented on August 27, 2024

I've looked into this the past 1-2 hours and I can't find a way to get the actual owned io::Error. std::error::Error::source exists, but it only returns an immutable reference. We'd need an owned value (or a mutable value to use with std::mem::replace and get the owned value).

from ureq.

algesten avatar algesten commented on August 27, 2024

@kangalioo I see the problem. .source() doesn't let us get the actual error. I've implemented a PR that clones the original error as closely as possible. See #123

from ureq.

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.