From dca3631aad56d135a8e42f70c956eb5f0fe35d4e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 5 Apr 2012 17:42:26 -0700 Subject: [PATCH] updated error parser to work with Nova EC2 error message --- .../jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java | 2 +- .../aws/handlers/ParseAWSErrorFromXmlContentTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java index 8c39c3b43f..7471bf47c5 100644 --- a/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java +++ b/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java @@ -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( diff --git a/common/aws/src/test/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContentTest.java b/common/aws/src/test/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContentTest.java index e65a67473d..6df230869c 100644 --- a/common/aws/src/test/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContentTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContentTest.java @@ -68,6 +68,12 @@ public class ParseAWSErrorFromXmlContentTest { assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "", "LoadBalancerNotFound", ResourceNotFoundException.class); } + + @Test + public void test400WithSecurityGroupNotFoundForProjectSetsResourceNotFoundException() { + assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "", + "SecurityGroupNotFoundForProject", ResourceNotFoundException.class); + } @Test public void test400WithUnsupportedCodeMakesUnsupportedOperationException() {