avadev / AvaTax-REST-V2-PHP-SDK

Sales Tax API SDK for PHP and AvaTax REST
https://developer.avalara.com/sdk/
Apache License 2.0
48 stars 95 forks source link

Try/catch is not firing on exception and server is responding with 502 error for transaction with invalid addresses #210

Closed matrixengine closed 1 year ago

matrixengine commented 1 year ago

Cannot get the system to catch exception and server returns a 502 response assumed to be when an invalid address is supplied as providing a valid address does not cause an error. Used to be able to see the exceptions thrown but a 502 response is sent immediately after $tb->create() using PHP SDK v23.7.0.

Invalid address: { "line1": "123 Test Street", "line2": "", "line3": null, "city": "City", "region": "Alabama", "postal_code": "12345", "country_code": "US" }

$client = new AvaTaxClient('Test', '1.0', 'n/a', 'sandbox'); $client->withLicenseKey(ACCOUNT_ID, KEY); $client->withCatchExceptions(true); //doesn't matter if I include, exclude to change true to false

$tb = new TransactionBuilder($client, 'Test', DocumentType::C_SALESORDER, $id);

....withLine()

$tb->withAddress('SingleLocation', $address_line1, $address_line2, $address_line3, $address_city, $address_region, $address_postal_code, $address_country_code);

$tb->create() is wrapped in try/catch with the following catch statements not firing and immediately producing a 502 response:

catch (\GuzzleHttp\Exception\ClientException $e) catch (\Exception $e) catch (\Throwable $e)

Has something changed that I need to configure to capture an exception in this regard?

Thank you.

matrixengine commented 1 year ago

If anyone experiences this in future, it was an issue in a php version between 8.1.x and 8.1.21. I cannot confirm which as I don't have a record of the prior version but I was on a version of 8.1 prior to 8.1.21. I had tried many things including server reboots to no avail. As soon as upgraded and rebooted once more, the exceptions started working again