package uk.co.prenderj.trail.util;

import android.os.AsyncTask;

public abstract class CheckedAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
    public abstract Result call(Params... params) throws Exception;
    
    public abstract void finish(Result result) throws Exception;
    
    @Override
    protected Result doInBackground(Params... params) {
        try {
            return call(params);
        } catch (Exception e) {
            onException(e);
            return null;
        }
    }
    
    @Override
    protected void onPostExecute(Result result) {
        try {
            finish(result);
        } catch (Exception e) {
            onException(e);
        }
    }
    
    public void onException(Exception thrown) {
        cancel(true);
    }
}

@@ -170,16 +170,51 @@
 sult%3E %7B%0A
+    private Exception thrown;%0A    %0A
     publ
@@ -505,38 +505,34 @@
             
-onException(e)
+thrown = e
 ;%0A          
@@ -627,24 +627,97 @@
 t result) %7B%0A
+        if (thrown != null) %7B%0A            onException(thrown);%0A        %7D%0A
         try 

Revert "Handle exception straight away"