When the exception is thrown by the message->invoke() method then I'm unable to get the error code. The only thing I can get is $e->getMessage() that returns just an error message string.
It would be good if there was a method that returns the native Nexmo response
Correct me if I'm wrong.
// Edit:
This is how i solved the problem, but this is not an elegant solution at all.
$message = $e->getMessage();
$response = [
'status' => null,
'errorMessage' => $message
];
$errorMessageArray = explode(' - status ', $message);
if (count($errorMessageArray) === 2) {
$response = [
'errorMessage' => $errorMessageArray[0],
'status' => $errorMessageArray[1]
];
}