Giter Club home page Giter Club logo

Comments (3)

g105b avatar g105b commented on June 26, 2024

Currently the 1st "basic usage" example works fully, but if it's forced to decode JSON with a syntax error the promise rejection is eaten up silently... investigating next.

from fetch.

g105b avatar g105b commented on June 26, 2024

This is harder than I thought it would be.

from fetch.

g105b avatar g105b commented on June 26, 2024

The entire codebase is greatly improved and tidy now, with more type safety, but this issue still remains as the only known bug.

public function json(int $depth = 512, int $options = 0):Promise {
$newDeferred = new Deferred();
$newPromise = $newDeferred->getPromise();
$deferredPromise = $this->deferred->getPromise();
$deferredPromise->then(function(string $resolvedValue)
use($newDeferred, $depth, $options) {
$builder = new JsonObjectBuilder($depth, $options);
try {
$json = $builder->fromJsonString($resolvedValue);
$newDeferred->resolve($json);
}
catch(JsonDecodeException $exception) {
$newDeferred->reject($exception);
}
});
return $newPromise;
}

This is where the issue lies, in the resolution of the JSON data. If the JSON data is invalid, like it is when used in example/01-basic-fetch.php, the exception is thrown rather than passed up the promise chain.

It's actually not a breaking issue, because it only represents internal failures (things like curl exceptions, timeouts or when $response->ok fails, are all still caught correctly). It might make sense to release the code in its currently improved state, then track this issue in a separate issue to return to later.

from fetch.

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.