mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Better logging for api exceptions.
This commit is contained in:
parent
0979b644ef
commit
cdea2d210d
@ -68,22 +68,30 @@ public class ApiDispatcher {
|
||||
cmd.callCreate();
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage());
|
||||
}else if (t instanceof PermissionDeniedException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage());
|
||||
}else if (t instanceof AccountLimitException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage());
|
||||
}else if (t instanceof InsufficientCapacityException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage());
|
||||
}else if (t instanceof ResourceAllocationException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage());
|
||||
}else if (t instanceof ResourceUnavailableException) {
|
||||
s_logger.warn(t);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage());
|
||||
}else if (t instanceof ServerApiException) {
|
||||
s_logger.warn(t);
|
||||
throw new ServerApiException(((ServerApiException) t).getErrorCode(), ((ServerApiException) t).getDescription());
|
||||
}else if (t instanceof AsyncCommandQueued) {
|
||||
throw (AsyncCommandQueued)t;
|
||||
}else {
|
||||
s_logger.warn(t);
|
||||
s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t);
|
||||
if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN)
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage());
|
||||
@ -99,22 +107,30 @@ public class ApiDispatcher {
|
||||
cmd.execute();
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage());
|
||||
}else if (t instanceof PermissionDeniedException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage());
|
||||
}else if (t instanceof AccountLimitException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage());
|
||||
}else if (t instanceof InsufficientCapacityException) {
|
||||
s_logger.info(t);
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage());
|
||||
}else if (t instanceof ResourceAllocationException) {
|
||||
s_logger.warn(t);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage());
|
||||
}else if (t instanceof ResourceUnavailableException) {
|
||||
s_logger.warn(t);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage());
|
||||
}else if (t instanceof ServerApiException) {
|
||||
s_logger.warn(t);
|
||||
throw new ServerApiException(((ServerApiException) t).getErrorCode(), ((ServerApiException) t).getDescription());
|
||||
} else if (t instanceof AsyncCommandQueued) {
|
||||
throw (AsyncCommandQueued)t;
|
||||
}else {
|
||||
s_logger.warn(t);
|
||||
s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t);
|
||||
if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN)
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user