klaviyo / php-klaviyo

PHP wrapper for the Klaviyo API
59 stars 47 forks source link

400 status code does not show details #40

Closed Kalo79 closed 3 years ago

Kalo79 commented 3 years ago

In "handleResponse" an exception is thrown when the status code is !=200, but that exception only contains the status code and does not include any details from the response. The 400 status may be due to different reasons and it would be nice if the exception contains the exact reason returned in the response.

remstone7 commented 3 years ago

Hey @Kalo79 - yes, we will add this!

Kalo79 commented 3 years ago

Here is how I'm doing it for now. It works for me. else if ( $statusCode != 200 ) { $ret=$statusCode.' ('.$this->decodeJsonResponse( $response )['detail'].')'; throw new KlaviyoException( sprintf( self::ERROR_NON_200_STATUS, $ret ) ); }