Description
We are using the MessageBirdClient.sendVoiceCall
method to initiate phone calls. We were able to catch exceptions when the voice call request fails. However, we also expected to be able to use the MessageBirdException.getErrors
method to pull out the particular error code returned (not just the HTTP status code). Instead, the method returns null
.
As per the code here and the status codes outlined in the API docs here: (eg. 25
for "not enough balance").
It looks to me like the issue is here in MessageBirdServiceImpl
where the body of the failed HTTP request is mapped onto the ErrorReport[] class. The fields of an error I received when testing the API via cURL ("message", "code") do not match the fields of the ErrorReport class ("description", "code", "parameter"):
{
"errors": [
{
"message": "You're not authorized to access this resource.",
"code": 14
}
]
}
vs
public class ErrorReport {
private Integer code;
private String description;
private String parameter;
...
I am not sure if those fields ErrorReport class are expected elsewhere or with different types of errors. The only one we were able to manually test is when we receive a 403 "unauthorized" for using the incorrect API key.
(CC: @katchengli)