bug 6857: if the dispatcher recieves an IllegalArgumentException, bubble that up to the response so the caller gets a useful message

This commit is contained in:
Kris McQueen 2010-10-29 14:04:58 -07:00
parent 003b41eca9
commit a9349cb815
1 changed files with 6 additions and 0 deletions

View File

@ -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) {