From a9349cb815a94ac82f37fd89642643829d1269bb Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Fri, 29 Oct 2010 14:04:58 -0700 Subject: [PATCH] bug 6857: if the dispatcher recieves an IllegalArgumentException, bubble that up to the response so the caller gets a useful message --- server/src/com/cloud/api/ApiDispatcher.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 2f3b366ad7e..b499afa0cad 100644 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -98,10 +98,14 @@ public class ApiDispatcher { Throwable cause = ite.getCause(); if (cause instanceof InvalidParameterValueException) { throw new ServerApiException(BaseCmd.PARAM_ERROR, cause.getMessage()); + } else if (cause instanceof IllegalArgumentException) { + throw new ServerApiException(BaseCmd.PARAM_ERROR, cause.getMessage()); } else if (cause instanceof PermissionDeniedException) { throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, cause.getMessage()); } else if (cause instanceof ResourceAllocationException){ throw new ServerApiException(BaseCmd.UNSUPPORTED_ACTION_ERROR, cause.getMessage()); + } else if (cause instanceof ServerApiException) { + throw (ServerApiException)cause; } s_logger.warn("Exception executing method " + methodName + " for command " + cmd.getClass().getSimpleName(), ite); throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Unable to execute method " + methodName + " for command " + cmd.getClass().getSimpleName() + ", internal error in the implementation."); @@ -149,6 +153,8 @@ public class ApiDispatcher { } if (cause instanceof InvalidParameterValueException) { throw new ServerApiException(BaseCmd.PARAM_ERROR, cause.getMessage()); + } else if (cause instanceof IllegalArgumentException) { + throw new ServerApiException(BaseCmd.PARAM_ERROR, cause.getMessage()); } else if (cause instanceof PermissionDeniedException) { throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, cause.getMessage()); } else if (cause instanceof ServerApiException) {