All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.akeyless.api.utils.APIErrorResponse Maven / Gradle / Ivy

There is a newer version: 0.0.10
Show newest version
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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy