From 737d2819273e7ba07d3a993422b138b93b852415 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sun, 11 Dec 2016 16:57:17 +0100 Subject: Handle jgit errors (#243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial work on the git error handling * remove throws exception and handle the jsch one correctly * move the commit task into its own operation * get rid of the interface and rely on the abstract class GitOperation * add error message to the pull command * add error message to the push command * add error message to the sync operationˆ --- .../java/com/zeapo/pwdstore/git/PullOperation.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java') diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java index abf4bfe6..6ca8bf49 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java @@ -1,6 +1,10 @@ package com.zeapo.pwdstore.git; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; + +import com.zeapo.pwdstore.R; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.PullCommand; @@ -32,10 +36,26 @@ public class PullOperation extends GitOperation { } @Override - public void execute() throws Exception { + public void execute() { if (this.provider != null) { ((PullCommand) this.command).setCredentialsProvider(this.provider); } - new GitAsyncTask(callingActivity, true, false, PullCommand.class).execute(this.command); + new GitAsyncTask(callingActivity, true, false, this).execute(this.command); + } + + @Override + public void onTaskEnded(String result) { + new AlertDialog.Builder(callingActivity). + setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). + setMessage("Error occured during the pull operation, " + + callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + + result + + "\nPlease check the FAQ for possible reasons why this error might occur."). + setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + callingActivity.finish(); + } + }).show(); } } -- cgit v1.2.3