Skip to content

Commit 52f8b6e

Browse files
committed
[fix]: [CI-4561]: Fixed error message
1 parent dc49f7d commit 52f8b6e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public WingsException handleException(Exception exception) {
3838
return NestedExceptionUtils.hintWithExplanationException(HintException.HINT_SCM_INVALID_REQUEST,
3939
ExplanationException.EXPLANATION_SCM_INVALID_REQUEST,
4040
new InvalidRequestException("SCM service running with delegate has error", USER));
41+
} else if (errorCode == ErrorCode.GIT_CONNECTION_ERROR) {
42+
return NestedExceptionUtils.hintWithExplanationException(HintException.HINT_INVALID_GIT_REPO,
43+
ExplanationException.INVALID_GIT_REPO, new InvalidRequestException(exception.getMessage(), USER));
44+
} else if (errorCode == ErrorCode.CONNECTION_TIMEOUT) {
45+
return NestedExceptionUtils.hintWithExplanationException(
46+
"Time out", "Time out explanation", new InvalidRequestException(exception.getMessage(), USER));
4147
}
4248
return new InvalidRequestException(exception.getMessage(), USER);
4349
}

960-api-services/src/main/java/io/harness/git/GitClientV2Impl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import io.harness.exception.WingsException;
4646
import io.harness.exception.YamlException;
4747
import io.harness.exception.runtime.JGitRuntimeException;
48+
import io.harness.exception.runtime.SCMRuntimeException;
4849
import io.harness.filesystem.FileIo;
4950
import io.harness.git.model.AuthInfo;
5051
import io.harness.git.model.ChangeType;
@@ -91,6 +92,7 @@
9192
import java.util.stream.Stream;
9293
import lombok.extern.slf4j.Slf4j;
9394
import net.jodah.failsafe.Failsafe;
95+
import net.jodah.failsafe.FailsafeException;
9496
import net.jodah.failsafe.RetryPolicy;
9597
import org.apache.commons.io.FileUtils;
9698
import org.apache.commons.lang3.StringUtils;
@@ -346,6 +348,18 @@ public void validateOrThrow(GitBaseRequest request) {
346348
log.info(gitClientHelper.getGitLogMessagePrefix(request.getRepoType()) + "Git validation failed [{}]", e);
347349
if (e instanceof GitAPIException) {
348350
throw new JGitRuntimeException(e.getMessage(), e);
351+
} else if (e instanceof FailsafeException) {
352+
if (e.getMessage().contains("upload-pack not found")) {
353+
throw SCMRuntimeException.builder()
354+
.message("Please provide correct git repo url")
355+
.errorCode(ErrorCode.GIT_CONNECTION_ERROR)
356+
.build();
357+
} else {
358+
throw SCMRuntimeException.builder()
359+
.message("Git connection timed out")
360+
.errorCode(ErrorCode.CONNECTION_TIMEOUT)
361+
.build();
362+
}
349363
} else {
350364
throw new GeneralException(e.getMessage(), e);
351365
}

0 commit comments

Comments
 (0)