Giter Club home page Giter Club logo

Comments (3)

davidtsadler avatar davidtsadler commented on August 24, 2024

There are a few options available.

Just catch the exception.

try
{
    $response =  $service->operation($request);
    // Handle successful response.
}
catch(Exception $e)
{
    /**
     * Add strategy for dealing with the exception. 
     * For example log exception message or re-try request.
     */
}

You can also get access to the actual Guzzle3 object that sends the request. The httpClient method returns the HttpClient object that the SDK uses for sending the request. This object uses a Guzzle3 instance that can be obained via the guzzle method. This will enable you to use some of the Guzzle3 plugins that are available.

use GuzzleHttp\Subscriber\Retry\RetrySubscriber;
/**
 * Use a plugin that retrys 500 and 503 responses.
 */
$retry = new RetrySubscriber([
    'filter' => RetrySubscriber::createStatusFilter()
]);

$service = new Services\TradingService(...);
/**
 * Attach pluging to Guzzle3 object.
 */
$service->httpClient()->guzzle()->getEmitter()->attach($retry);

$response =  $service->operation($request);

It's also possible to supply the SDK with your own HTTP client and let that handle the actual request. You can then implement what ever retry mechanisam and error handling that you feel is suitable for your project. There is an example available that shows how to use cURL to send requests to the API.

from ebay-sdk-php.

itsonit avatar itsonit commented on August 24, 2024

Thank you for your detailed reply! (:

I had already tried to catch the exception globally, but that did not work.

I will try to solve it with Guzzle RetrySubscriber as you described.

from ebay-sdk-php.

itsonit avatar itsonit commented on August 24, 2024

Shame on me. I had just catched a CurlException, and no general Exception.. Sorry for the noise.

from ebay-sdk-php.

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.