Ensure S3Exception has message

Also add missing toString implementation.
pull/176/merge
Andrew Gaul 2016-11-14 15:34:36 -08:00
rodzic 34c36e4236
commit 3d9a7120ce
2 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -44,7 +44,7 @@ public final class S3Exception extends Exception {
S3Exception(S3ErrorCode error, String message, Throwable cause,
Map<String, String> elements) {
super(message, cause);
super(requireNonNull(message), cause);
this.error = requireNonNull(error);
this.elements = ImmutableMap.copyOf(elements);
}
@ -56,4 +56,9 @@ public final class S3Exception extends Exception {
Map<String, String> getElements() {
return elements;
}
@Override
public String toString() {
return error + " " + elements;
}
}

Wyświetl plik

@ -1079,7 +1079,8 @@ public class S3ProxyHandler {
}
if (!created) {
throw new S3Exception(S3ErrorCode.BUCKET_ALREADY_OWNED_BY_YOU,
null, null, ImmutableMap.of("BucketName", containerName));
S3ErrorCode.BUCKET_ALREADY_OWNED_BY_YOU.getMessage(),
null, ImmutableMap.of("BucketName", containerName));
}
response.addHeader(HttpHeaders.LOCATION, "/" + containerName);