TomorrowIdeas / plaid-sdk-php

PHP bindings for the Plaid API
MIT License
114 stars 44 forks source link

item_errors are reduced to a "Bad Request" error, instead of forwarding the item error from Plaid #21

Closed vjotchere closed 4 years ago

vjotchere commented 4 years ago

When a request to a plaid endpoint fails due to an item error, typically from functions like 'getAccounts' and 'getTransactions', the PlaidRequestException outputs "Bad Request". It would be most useful for the exception handler to forward the error message sent from plaid using something like \json_decode($response->getBody()->getContents()) so that that error message can be forwarded to the end users in instances where an update needs to happen through Link

brentscheffler commented 4 years ago

It should already do this.

When the exception is thrown, the entire Response object is passed into the exception and then parsed. The exception code should match the HTTP status code. The exception message should also be passed through from the Response as well, unless Plaid changed the shape of their error responses.

The PlaidRequestException instance also has a getResponse() method that will return the JSON decoded error object from Plaid.

brentscheffler commented 4 years ago

$plaidRequestException->getCode(); // Should match the HTTP response code Plaid returned
$plaidRequestException->getMessage(); // Should be the display message from Plaid
$plaidRequestException->getResponse(); // Should be the full JSON decoded object Plaid returned in response body
vjotchere commented 4 years ago

the getResponse() method was what I was looking for and missed, thank you