diff --git a/api/src/main/java/com/messagebird/objects/ErrorReport.java b/api/src/main/java/com/messagebird/objects/ErrorReport.java index 00c74aa9..d0d63d5a 100644 --- a/api/src/main/java/com/messagebird/objects/ErrorReport.java +++ b/api/src/main/java/com/messagebird/objects/ErrorReport.java @@ -1,32 +1,40 @@ package com.messagebird.objects; +import com.fasterxml.jackson.annotation.JsonInclude; /** * When MessageBird returns a 4xx, you will find a list of any error codes in your return dataset. * you will receive a list of errors from the API in such case. * * Created by rvt on 1/5/15. */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) public class ErrorReport { private Integer code; private String description; private String parameter; + private String message; public ErrorReport() { } - public ErrorReport(Integer code, String description, String parameter) { + public ErrorReport(Integer code, String description, String parameter, String message) { this.code = code; this.description = description; this.parameter = parameter; + this.message = message; } @Override public String toString() { - return "ErrorReport{" + - "code=" + code + - ", description='" + description + '\'' + - ", parameter='" + parameter + '\'' + - '}'; + String str = "ErrorReport{code=" + code; + if (message != null && !message.isEmpty()) { + str = str.concat(", message='" + message + "'"); + } else { + str = str.concat(", description='" + description + "'"); + str = str.concat(", parameter='" + parameter + "'"); + } + str = str.concat("}"); + return str; } /** @@ -53,4 +61,11 @@ public String getParameter() { return parameter; } + /** + * message not null for only voice API response + * @return + */ + public String getMessage() { + return message; + } }