package com.apibootstraper.mobile.core.util;

import android.util.Log;

public class HTTPResponse<T> {

    /**
     * Fired when the request is started, override to handle in your own code
     */
    public void onStart() {}

    /**
     * Fired in all cases when the request is finished, after both success and failure, override to handle in your own code
     */
    public void onFinish() {}

    /**
     * 
     * @param response
     */
    public void onSuccess(T object) {}

    /**
     * 
     * @param statusCode
     * @param object
     */
    public void onSuccess(int statusCode, T object) {
        onSuccess(object);
    }

    /**
     * Fired when a request fails to complete, override to handle in your own code
     * @param error the underlying cause of the failure
     */
    public void onFailure(Throwable error) {
    	error.printStackTrace();
        Log.e("HTTPResponse", error.getMessage());
    }

    /**
     * Fired when a request fails to complete, override to handle in your own code
     * @param error the underlying cause of the failure
     * @param content the response body, if any
     */
    public void onFailure(Throwable error, String content) {
        onFailure(error);
        Log.e("HTTPResponse", content);
    }
}

@@ -39,16 +39,72 @@
 .util;%0A%0A
+import org.json.JSONArray;%0Aimport org.json.JSONObject;%0A%0A
 import a
@@ -120,16 +120,16 @@
 il.Log;%0A
-
 %0Apublic 
@@ -776,32 +776,40 @@
 n your own code%0A
+     * %0A
      * @param er
@@ -893,20 +893,16 @@
 owable e
-rror
 ) %7B%0A    
@@ -903,20 +903,16 @@
 %7B%0A    %09e
-rror
 .printSt
@@ -954,20 +954,16 @@
 onse%22, e
-rror
 .getMess
@@ -1064,24 +1064,32 @@
 ur own code%0A
+     * %0A
      * @para
@@ -1229,28 +1229,254 @@
 le e
-rror, String content
+, JSONObject errorResponse) %7B%0A        onFailure(e);%0A        Log.e(%22HTTPResponse%22, errorResponse.toString());%0A    %7D%0A%0A    /**%0A     * %0A     * @param e%0A     * @param errorResponse%0A     */%0A    public void onFailure(Throwable e, JSONArray errorResponse
 ) %7B%0A
@@ -1494,20 +1494,16 @@
 ailure(e
-rror
 );%0A     
@@ -1527,23 +1527,40 @@
 ponse%22, 
-content
+errorResponse.toString()
 );%0A    %7D

Update HTTPResponse