Giter VIP home page Giter VIP logo

Comments (5)

dasper avatar dasper commented on July 19, 2024 2

An underlying issue is that Guzzle throws a RequestException which the documentation does not show anywhere and naturally truncates data after 120 characters. This means any data AvaTax sends after 120 characters is useless to the developers.

Furthermore, setting catch exceptions to false almost always sends the same stack trace that points to RequestException.php line 113 because Guzzle is reading the HTTP error codes. If you want the AvaTax error to match their documentation, you will need to catch the exception and return the response body similar to this:

if ($exception instanceof \GuzzleHttp\Exception\RequestException) {
    $body = $exception->getResponse()->getBody();
    $errorInfo = json_decode($body->read($body->getSize()));
}

Edit: fixed formatting and had json_decode return an object to match Avalara\ErrorInfo

from avatax-rest-v2-php-sdk.

jondmcelroy avatar jondmcelroy commented on July 19, 2024

I believe you can set the client to not catch exceptions and actually throw them:

$client = new AvaTaxClient(...);
$client->withCatchExceptions(false);

from avatax-rest-v2-php-sdk.

jondmcelroy avatar jondmcelroy commented on July 19, 2024

I believe you can get the full exception response string just by casting the body to a string.

$errorMessage = (string)$throwable->getResponse()->getBody();

from avatax-rest-v2-php-sdk.

dasper avatar dasper commented on July 19, 2024

Yep, this is correct, the StreamInterface has a __toString method defined but one thing to note is PHP does not allow throwing an exception while casting to a string so if there was some underlying throwable, you will get an empty string back rather than the throwable which could make it harder to debug.

from avatax-rest-v2-php-sdk.

svc-developer avatar svc-developer commented on July 19, 2024

This issue is fixed as part of #183. Please verify and revert if in case it is not resolved at your end.

from avatax-rest-v2-php-sdk.

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.