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

com.gocardless.errors.ApiErrorResponse Maven / Gradle / Ivy

package com.gocardless.errors;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import java.util.List;

public class ApiErrorResponse {
    private static final Joiner JOINER = Joiner.on(", ");
    private final String message;
    private final ErrorType type;
    private final String documentationUrl;
    private final String requestId;
    private final int code;
    private final List errors;

    private ApiErrorResponse(String message, ErrorType type, String documentationUrl,
            String requestId, int code, List errors) {
        this.message = message;
        this.type = type;
        this.documentationUrl = documentationUrl;
        this.requestId = requestId;
        this.code = code;
        this.errors = errors;
    }

    String getMessage() {
        return message;
    }

    ErrorType getType() {
        return type;
    }

    String getDocumentationUrl() {
        return documentationUrl;
    }

    String getRequestId() {
        return requestId;
    }

    int getCode() {
        return code;
    }

    List getErrors() {
        if (errors == null) {
            return ImmutableList.of();
        }
        return ImmutableList.copyOf(errors);
    }

    @Override
    public String toString() {
        if (errors == null || errors.isEmpty()) {
            return message;
        } else {
            return JOINER.join(errors);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy