Search in sources :

Example 1 with RequestException

use of com.github.natanbc.reliqua.request.RequestException in project Ree6 by Ree6-Applications.

the class RequestUtils method handleError.

public static <T> void handleError(RequestContext<T> context) {
    Response response = context.getResponse();
    ResponseBody body = response.body();
    if (body == null) {
        context.getErrorConsumer().accept(new RequestException("Unexpected status code " + response.code() + " (No body)", context.getCallStack()));
        return;
    }
    JSONObject json = null;
    try {
        json = toJSONObject(response);
    } catch (JSONException ignored) {
    }
    handleErrorCode(json, context);
}
Also used : Response(okhttp3.Response) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) RequestException(com.github.natanbc.reliqua.request.RequestException) ResponseBody(okhttp3.ResponseBody)

Aggregations

RequestException (com.github.natanbc.reliqua.request.RequestException)1 Response (okhttp3.Response)1 ResponseBody (okhttp3.ResponseBody)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1