-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
Description
Hi MessageBird team,
I'm having some inconveniences handling MessageBirdExceptions.
My code looks like this:
try {
$this->messageBirdClient->messages->create($message);
} catch (MessageBirdException $e) {
$this->writeln($e->getMessage()); // console output
}
It works fine but in case of catching certain exceptions types $e->getMessage() returns null (see https://github.com/messagebird/php-rest-api/blob/master/src/MessageBird/Common/ResponseError.php#L44). At the same time reasonable error message is returned in a response:
...
["errors"]=>
array(1) {
[0]=>
object(stdClass)#62 (3) {
["code"]=>
int(2)
["description"]=>
string(42) "Request not allowed (incorrect access_key)"
["parameter"]=>
string(10) "access_key"
}
}
...
Because of this I have to handle these cases separately which is not what I want to do.
My suggestion is to add error description to MessageBirdException in all cases.
Thanks,
Andrey