com.akeyless.api.utils.APIErrorResponse Maven / Gradle / Ivy
package com.akeyless.api.utils;
import com.akeyless.api.exceptions.ApiCommunicationException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
public class APIErrorResponse {
private String error;
private String message;
public APIErrorResponse(String error, String message) {
this.error = error;
this.message = message;
}
public APIErrorResponse() {
this.error = null;
this.message = null;
}
public String getError() {
return error;
}
public String getMessage() {
return message;
}
public void setError(String error) {
this.error = error;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return "Error:" + error + ", Message:" + message ;
}
public static APIErrorResponse getInstance(Exception exception, String body) throws ApiCommunicationException {
if (body == null) {
throw new ApiCommunicationException("Internal Error: null body");
}
try {
return new ObjectMapper().readValue(body, APIErrorResponse.class);
} catch (IOException e) {
throw new ApiCommunicationException(exception);
}
}
}