io.github.jpmorganchase.fusion.api.tools.ResponseChecker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fusion-sdk Show documentation
Show all versions of fusion-sdk Show documentation
A Java SDK for the Fusion platform API
package io.github.jpmorganchase.fusion.api.tools;
import io.github.jpmorganchase.fusion.api.exception.APICallException;
import io.github.jpmorganchase.fusion.http.HttpResponse;
public class ResponseChecker {
/**
* @param response to be verified
* @param type expected in the body of the response
* @throws APICallException indicating a failure to communicate with Fusion API
*/
public static void checkResponseStatus(HttpResponse response) throws APICallException {
if (response.isError()) {
throw new APICallException(response.getStatusCode(), extractErrorDetailFromBody(response));
}
}
private static String extractErrorDetailFromBody(final HttpResponse response) {
if (null != response.getBody()) {
return RegexBasedErrorParser.get(response.getBody().toString());
}
return RegexBasedErrorParser.UNKNOWN;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy