updated error parser to work with Nova EC2 error message

This commit is contained in:
Adrian Cole 2012-04-05 17:42:26 -07:00
parent 00c7179f72
commit dca3631aad
2 changed files with 7 additions and 1 deletions

View File

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

View File

@ -69,6 +69,12 @@ public class ParseAWSErrorFromXmlContentTest {
"<Error><Code>LoadBalancerNotFound</Code></Error>", ResourceNotFoundException.class);
}
@Test
public void test400WithSecurityGroupNotFoundForProjectSetsResourceNotFoundException() {
assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "",
"<Error><Code>SecurityGroupNotFoundForProject</Code></Error>", ResourceNotFoundException.class);
}
@Test
public void test400WithUnsupportedCodeMakesUnsupportedOperationException() {
assertCodeMakes("POST", URI.create("https://ec2.us-west-1.amazonaws.com/"), 400, "",