com.gocardless.errors.ApiError Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gocardless-pro Show documentation
Show all versions of gocardless-pro Show documentation
Client library for accessing the GoCardless Pro API
package com.gocardless.errors;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
/**
* Representation of an individual error handling an API request.
*/
public class ApiError {
private static final Joiner JOINER = Joiner.on(" ").skipNulls();
private final String message;
private final String reason;
private final String field;
private final String requestPointer;
private final Map links;
private ApiError(String message, String reason, String field, String requestPointer,
Map links) {
this.message = message;
this.reason = reason;
this.field = field;
this.requestPointer = requestPointer;
this.links = links;
}
/**
* Returns a message describing the problem.
*/
public String getMessage() {
return message;
}
/**
* Returns a key identifying the reason for this error.
*/
public String getReason() {
return reason;
}
/**
* Returns the field that this error applies to.
*/
public String getField() {
return field;
}
/**
* Returns the request pointer, indicating the exact field of the request that triggered the
* validation error
*/
public String getRequestPointer() {
return requestPointer;
}
/**
* Returns the IDs of related objects.
*/
public Map getLinks() {
if (links == null) {
return ImmutableMap.of();
}
return ImmutableMap.copyOf(links);
}
@Override
public String toString() {
return JOINER.join(field, message);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy