Skip to content

Conversation

@zaporylie
Copy link
Contributor

Hi

I work on SparkPost module for Drupal. I had some troubles sending email and Exception message and Code doesn't really help to investigate what was the source of the problem. API response has quite nice error message handling so I've added arguments to APIResponseException definition to aggregate API error messages.

__construct($message = "", $code = 0, $apiMessage = "", $apiCode = 0, $apiMessageDescription = "")

where

$message is custom message,
$code is HTTP status Code,
$apiMessage is API error message received from endpoint,
$apiCode is API error code received from endpoint,
$apiMessageDescription is API error message description received from endpoint.

Nothing special but it should improve DX, fix #44 and is backward compatible.

@chandon
Copy link
Contributor

chandon commented Mar 10, 2016

+1

* Gets the Exception message
* @return string the Exception message as a string.
*/
public function getAPIMessageDescription() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the field names from the API, what do you think about calling this method getAPIDescription?

@richleland
Copy link
Contributor

Hi @zaporylie this PR looks great - can we get the methods on the exception class covered? https://coveralls.io/builds/5351334/source?filename=lib%2FSparkPost%2FAPIResponseException.php

@zaporylie
Copy link
Contributor Author

Renamed getAPIMessageDescription to getAPIDescription, added APIResourceExceptionTest

richleland added a commit that referenced this pull request Mar 14, 2016
…eption

Improve APIResponseException class
@richleland richleland merged commit 2bac548 into SparkPost:master Mar 14, 2016
@richleland
Copy link
Contributor

Thanks for the contribution @zaporylie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 4XX errors body to exception

3 participants