aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/connector/oc/OkapiClient.java')
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OkapiClient.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
index f4bac08..fbcda18 100644
--- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
@@ -822,6 +822,21 @@ final class OkapiClient {
}
/**
+ * Retrieves error information from an unsuccessful Okapi-response
+ *
+ * @param response
+ * response containing an error object
+ * @return OkapiError object with detailed information
+ */
+ public static OkapiError decodeErrorResponse(HttpResponse response) {
+ final JSONResult result = new JSONResult(response);
+ if (!result.isSuccess) {
+ return new OkapiError(result.data);
+ }
+ return new OkapiError(new JSONObject());
+ }
+
+ /**
* Encapsulates response state and content of an HTTP-request that expects a JSON result. <code>isSuccess</code> is
* only true, if the response state was success and <code>data</code> is not null.
*/