From d09785eaec07d9842755478f43544df1146d84d4 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Fri, 30 May 2014 12:16:35 +0200 Subject: [PATCH] Improved error message --- .../digitalocean/compute/util/LocationNamingUtils.java | 6 ++++-- .../digitalocean/compute/util/LocationNamingUtilsTest.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java index abbf4dc27..bca8e9cd8 100644 --- a/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java +++ b/digitalocean/src/main/java/org/jclouds/digitalocean/compute/util/LocationNamingUtils.java @@ -39,7 +39,8 @@ public static int extractRegionId(Location location) { checkNotNull(location, "location cannot be null"); String regionIdAndName = location.getDescription(); int index = regionIdAndName.indexOf('/'); - checkArgument(index >= 0, "location description should be in the form 'regionId/regionName'"); + checkArgument(index >= 0, "location description should be in the form 'regionId/regionName' but was: %s", + regionIdAndName); return Integer.parseInt(regionIdAndName.substring(0, index)); } @@ -53,7 +54,8 @@ public static String extractRegionName(Location location) { checkNotNull(location, "location cannot be null"); String regionIdAndName = location.getDescription(); int index = regionIdAndName.indexOf('/'); - checkArgument(index >= 0, "location description should be in the form 'regionId/regionName'"); + checkArgument(index >= 0, "location description should be in the form 'regionId/regionName' but was: %s", + regionIdAndName); return regionIdAndName.substring(index + 1); } diff --git a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java index 4f5ec064c..724f0ad5b 100644 --- a/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java +++ b/digitalocean/src/test/java/org/jclouds/digitalocean/compute/util/LocationNamingUtilsTest.java @@ -55,7 +55,7 @@ public void testExtractRegionIdNullLocation() { extractRegionId(null); } - @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName'") + @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName' but was: foobar") public void testExtractRegionIdWithoutEncodedForm() { extractRegionId(location("foobar")); } @@ -79,7 +79,7 @@ public void testExtractRegionNameNullLocation() { extractRegionId(null); } - @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName'") + @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "location description should be in the form 'regionId/regionName' but was: foobar") public void testExtractRegionNameWithoutEncodedForm() { extractRegionId(location("foobar")); }