Skip to content

Commit

Permalink
#5 Better logging on failure to fetch artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
manojlds committed Mar 1, 2015
1 parent d57702a commit f2d1f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public ExecutionResult execute(TaskConfig config, final TaskExecutionContext con
try {
store.getPrefix(artifactPathOnS3, destination);
} catch (Exception e) {
return ExecutionResult.failure("Failure while downloading artifacts", e);
String message = String.format("Failure while downloading artifacts - %s", e.getMessage());
logger.error(message, e);
return ExecutionResult.failure(message, e);
}

return ExecutionResult.success("Fetched all artifacts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public void shouldBeFailureIfUnableToFetchArtifacts() {
Map<String, String> mockVariables = mockEnvironmentVariables.build();
AmazonS3Client mockClient = mockClient();
doReturn(mockClient).when(fetchExecutor).s3Client(any(GoEnvironment.class));
doThrow(new AmazonClientException("Exception")).when(mockClient).listObjects(any(ListObjectsRequest.class));
doThrow(new AmazonClientException("Exception message")).when(mockClient).listObjects(any(ListObjectsRequest.class));

ExecutionResult executionResult = fetchExecutor.execute(config, mockContext(mockVariables));

assertFalse(executionResult.isSuccessful());
assertThat(executionResult.getMessagesForDisplay(), is("Failure while downloading artifacts"));
assertThat(executionResult.getMessagesForDisplay(), is("Failure while downloading artifacts - Exception message"));
}

@Test
Expand Down

0 comments on commit f2d1f59

Please sign in to comment.