diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 533f6fa6162..2022ddeb6e6 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -385,9 +385,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.secondary_storage); } - ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); - if (imgfmt == null) { - throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values())); + try { + ImageFormat.valueOf(format.toUpperCase()); + } catch (IllegalArgumentException e) { + s_logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); + throw new IllegalArgumentException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); } // Check that the the disk offering specified is valid diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index 8bb93dd41ad..c5d0c5b261f 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -198,9 +198,12 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat featured = Boolean.FALSE; } - ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); - if (imgfmt == null) { - throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values())); + ImageFormat imgfmt; + try { + imgfmt = ImageFormat.valueOf(format.toUpperCase()); + } catch (IllegalArgumentException e) { + s_logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); + throw new IllegalArgumentException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); } // Check that the resource limit for templates/ISOs won't be exceeded