JCLOUDS-44: Map TooManyBuckets to proper exception

This commit is contained in:
Andrew Gaul 2013-05-14 15:55:30 -07:00
parent e5a43385b3
commit af7c003582
2 changed files with 13 additions and 0 deletions

View File

@ -103,6 +103,8 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
exception = new UnsupportedOperationException(message, exception);
else if ("AddressLimitExceeded".equals(errorCode))
exception = new InsufficientResourcesException(message, exception);
else if ("TooManyBuckets".equals(errorCode))
exception = new InsufficientResourcesException(message, exception);
else if (errorCode != null && (errorCode.indexOf("NotFound") != -1 || errorCode.endsWith(".Unknown")))
exception = new ResourceNotFoundException(message, exception);
else if ("IncorrectState".equals(errorCode)

View File

@ -99,6 +99,17 @@ public class ParseAWSErrorFromXmlContentTest {
InsufficientResourcesException.class);
}
@Test
public void test400WithTooManyBucketsCodeMakesInsufficientResourcesException() {
assertCodeMakes(
POST,
URI.create("https://ec2.us-east-1.amazonaws.com/"),
BAD_REQUEST.getStatusCode(),
"",
"<Response><Errors><Error><Code>TooManyBuckets</Code><Message>You have attempted to create more buckets than allowed</Message></Error></Errors><RequestID>c14f531a-cc35-4b48-8149-2655c7e6dc76</RequestID></Response>",
InsufficientResourcesException.class);
}
@Test
public void test400WithInUseCodeSetsIllegalStateException() {
assertCodeMakes(GET, URI.create("https://amazonaws.com/foo"), BAD_REQUEST.getStatusCode(), "",