aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
diff options
context:
space:
mode:
authorMohamed Zenadi <zeapo@users.noreply.github.com>2016-12-11 16:57:17 +0100
committerGitHub <noreply@github.com>2016-12-11 16:57:17 +0100
commit737d2819273e7ba07d3a993422b138b93b852415 (patch)
treed3f03de3764a39560b24e1b550bc0eed2feedd38 /app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
parentfd9e958d40a56a2a3b8dfbef86944d3d5f53fec2 (diff)
downloadHardenedPass-737d2819273e7ba07d3a993422b138b93b852415.tar.gz
HardenedPass-737d2819273e7ba07d3a993422b138b93b852415.zip
Handle jgit errors (#243)
* 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ˆ
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java24
1 files changed, 22 insertions, 2 deletions
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();
}
}