Added more error logging to api commands.

This commit is contained in:
alena 2010-12-07 14:38:34 -08:00
parent d6af02bb0e
commit 01b4af3006
20 changed files with 30 additions and 2 deletions

View File

@ -125,6 +125,7 @@ public class AddHostCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -84,6 +84,7 @@ public class AddSecondaryStorageCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -146,6 +146,7 @@ public class AddVpnUserCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -92,10 +92,14 @@ public class AssociateIPAddrCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign ip address");
}
} catch (ResourceAllocationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
} catch (InsufficientAddressCapacityException ex) {
s_logger.info(ex);
s_logger.trace(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
}
}

View File

@ -117,6 +117,7 @@ public class CopyIsoCmd extends BaseAsyncCmd {
isoResponse.setResponseName(getName());
this.setResponseObject(isoResponse);
} catch (StorageUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}

View File

@ -119,6 +119,7 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
this.setResponseObject(templateResponse);
} catch (StorageUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}

View File

@ -110,6 +110,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd implements Lo
try {
result = _lbService.createLoadBalancerRule(this);
} catch (NetworkRuleConflictException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
}
LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);

View File

@ -116,6 +116,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements
fwResponse.setResponseName(getName());
setResponseObject(fwResponse);
} catch (NetworkRuleConflictException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
}
}

View File

@ -167,8 +167,10 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create remote access vpn");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -136,6 +136,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
}
} catch (ResourceAllocationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
}
}

View File

@ -118,10 +118,13 @@ public class CreateStoragePoolCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
}
} catch (ResourceAllocationException ex1) {
s_logger.warn("Exception: ", ex1);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex1.getMessage());
}catch (ResourceInUseException ex2) {
s_logger.warn("Exception: ", ex2);
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
} catch (UnknownHostException ex3) {
s_logger.warn("Exception: ", ex3);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
}
}

View File

@ -136,8 +136,10 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create vlan ip range");
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
} catch (InsufficientCapacityException ex) {
s_logger.info(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
}
}

View File

@ -118,6 +118,7 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete remote access vpn");
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -128,6 +128,7 @@ public class ExtractIsoCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract iso");
}
} catch (InternalErrorException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -146,7 +146,8 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract volume");
}
} catch (URISyntaxException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
s_logger.info(ex);
throw new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
}
}
}

View File

@ -108,6 +108,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
}
} catch (AgentUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}

View File

@ -71,6 +71,7 @@ public class RecoverVMCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recover vm");
}
} catch (ResourceAllocationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
}
}

View File

@ -134,6 +134,7 @@ public class RegisterIsoCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register iso");
}
} catch (ResourceAllocationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
}
}

View File

@ -177,9 +177,11 @@ public class RegisterTemplateCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
}
} catch (ResourceAllocationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
} catch (URISyntaxException ex1) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex1.getMessage());
s_logger.info(ex1);
throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
}
}
}

View File

@ -121,6 +121,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}