com.tambapps.http.hyperpoet.ProblemResponseException Maven / Gradle / Ivy
package com.tambapps.http.hyperpoet;
import com.tambapps.http.hyperpoet.util.CachedResponseBody;
import lombok.Getter;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
/**
* Error response exception containing data for JSON RFC 7807 Problem details
*/
public class ProblemResponseException extends ErrorResponseException {
@Getter
private final Map members;
protected ProblemResponseException(int code, ResponseBody body,
Map headers, String message, Map members) {
super(code, body, headers, message);
this.members = members;
}
public String getType() {
return (String) members.get("type");
}
public String getTitle() {
return (String) members.get("title");
}
public String getDetail() {
return (String) members.get("detail");
}
public Integer getStatus() {
Number number = (Number) members.get("status");
return number != null ? number.intValue() : null;
}
public String getInstance() {
return (String) members.get("instance");
}
public Object getMember(String propertyName) {
return members.get(propertyName);
}
public Object getAt(String propertyName) {
return getMember(propertyName);
}
public static ProblemResponseException from(Response response, Function
© 2015 - 2024 Weber Informatics LLC | Privacy Policy