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); exception = new UnsupportedOperationException(message, exception);
else if ("AddressLimitExceeded".equals(errorCode)) else if ("AddressLimitExceeded".equals(errorCode))
exception = new InsufficientResourcesException(message, exception); 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); exception = new ResourceNotFoundException(message, exception);
else if ("IncorrectState".equals(errorCode) else if ("IncorrectState".equals(errorCode)
|| (errorCode != null && (error.getCode().endsWith(".Duplicate") | error.getCode().endsWith( || (errorCode != null && (error.getCode().endsWith(".Duplicate") | error.getCode().endsWith(

View File

@ -68,6 +68,12 @@ public class ParseAWSErrorFromXmlContentTest {
assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "", assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "",
"<Error><Code>LoadBalancerNotFound</Code></Error>", ResourceNotFoundException.class); "<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 @Test
public void test400WithUnsupportedCodeMakesUnsupportedOperationException() { public void test400WithUnsupportedCodeMakesUnsupportedOperationException() {