Skip to content

Is there any way to get an error message when the exception is thrown by the message->invoke() method? #25

@wujekbogdan

Description

@wujekbogdan

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]
    ];

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions