From fbc9fde75e650990d7ce3e5035d53e45f6575ddb Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 29 Sep 2020 21:11:14 +0530 Subject: Unwrap root cause for InvalidRemoteException (#1122) * BaseGitActivity: unwrap root cause for InvalidRemoteException as well JGit's InvalidRemoteException, like TransportException, swallows more useful errors as is clear from this (redacted) snippet. ``` D org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin D at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:26) D at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:41) D at com.zeapo.pwdstore.git.GitCommandExecutor$execute$2$result$1.invokeSuspend(GitCommandExecutor.kt:2) D at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3) D at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:15) D at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1) D at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:13) D Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: ssh://msfjarvis@[fe80::dead:beef]:22/pass-repo: fatal: '/pass-repo' does not appear to be a git repository D at org.eclipse.jgit.transport.TransportGitSsh.cleanNotFound(TransportGitSsh.java:14) D at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:20) D at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:1) D at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:1) D at org.eclipse.jgit.transport.Transport.fetch(Transport.java:20) D at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:18) ``` Signed-off-by: Harsh Shandilya * Add changelog entry Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt index b0aed087..36b8b6fb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt @@ -128,11 +128,12 @@ abstract class BaseGitActivity : AppCompatActivity() { */ private fun rootCauseException(throwable: Throwable): Throwable { var rootCause = throwable - // JGit's TransportException hides the more helpful SSHJ exceptions. + // JGit's InvalidRemoteException and TransportException hide the more helpful SSHJ exceptions. // Also, SSHJ's UserAuthException about exhausting available authentication methods hides // more useful exceptions. while ((rootCause is org.eclipse.jgit.errors.TransportException || rootCause is org.eclipse.jgit.api.errors.TransportException || + rootCause is org.eclipse.jgit.api.errors.InvalidRemoteException || (rootCause is UserAuthException && rootCause.message == "Exhausted available authentication methods"))) { rootCause = rootCause.cause ?: break -- cgit v1.2.3