Skip to content

Commit

Permalink
refactor(scm/test): separated SpinnakerNetworkException and Spinnaker…
Browse files Browse the repository at this point in the history
…HttpException exceptions for readability
  • Loading branch information
SheetalAtre committed Sep 11, 2023
1 parent 92e8073 commit f225284
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.netflix.spinnaker.igor.service.BuildProperties;
import com.netflix.spinnaker.igor.travis.client.logparser.PropertyParser;
import com.netflix.spinnaker.kork.core.RetrySupport;
import com.netflix.spinnaker.kork.exceptions.SpinnakerException;
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException;
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerNetworkException;
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerServerException;
Expand Down Expand Up @@ -177,17 +176,20 @@ private Map<String, Object> getPropertyFileFromLog(String projectId, Integer pip

return properties;

} catch (SpinnakerServerException e) {
// retry on network issue, 404 and 5XX
if (e instanceof SpinnakerNetworkException
|| (e instanceof SpinnakerHttpException
&& (((SpinnakerHttpException) e).getResponseCode() == 404
|| ((SpinnakerHttpException) e).getResponseCode() >= 500))) {
} catch (SpinnakerNetworkException e) {
// retry on network issue
throw e;
} catch (SpinnakerHttpException e) {
// retry on 404 and 5XX
if (e.getResponseCode() == 404 || e.getResponseCode() >= 500) {
throw e;
}
SpinnakerException ex = new SpinnakerException(e);
ex.setRetryable(false);
throw ex;
e.setRetryable(false);
throw e;
} catch (SpinnakerServerException e) {
// do not retry
e.setRetryable(false);
throw e;
} catch (IOException e) {
log.error("Error while parsing GitLab CI log to build properties", e);
return properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class CommitController extends AbstractCommitController {
} else if(e instanceof SpinnakerHttpException && ((SpinnakerHttpException)e).getResponseCode() == 404) {
return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, master.baseUrl)
}
log.error("Unhandled error response, acting like commit response was not found", e)
return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, master.baseUrl)
}

commitsResponse.commits.each {
Expand Down

0 comments on commit f225284

Please sign in to comment.