Last active
August 29, 2015 14:15
-
-
Save ignu/81ab14d8bcce8c98e191 to your computer and use it in GitHub Desktop.
"snapshotshot 4"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void handleException(Exception e) { | |
String[] error = e.getMessage().split("Error Code - "); | |
String errorMessage = error[0]; | |
if (error.length == 2) { // error code has been supplied | |
int errorCode = Integer.parseInt(error[1]); | |
if (errorCode == 431) { | |
// ... | |
} else if (errorMessage.contains("Can't delete snapshotshot 4 due to it is not in BackedUp Status")) { | |
throw new EC2ServiceException(ClientError.IncorrectState, "Specified snapshot is not in the correct state 'completed' for deletion"); | |
} else if (errorMessage.contains("Public key is invalid")) { | |
throw new EC2ServiceException(ClientError.InvalidKeyPair_Format, "Format of the specified key is invalid"); | |
} else if (errorMessage.contains("Invalid resource type")) { | |
throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified resourceId is invalid"); | |
} else if (errorMessage.contains("Unable to find tags by parameters specified")) { | |
throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified resourceTag for the specified resourceId doesn't exist"); | |
} else if (errorMessage.contains("Failed to enable static nat for the ip address with specified ipId " | |
+ "as vm with specified vmId is already associated with specified currentIp")) { | |
throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified publicIp is already associated to the specified VM"); | |
} else if (errorMessage.contains("Specified IP address id is not associated with any vm Id")) { | |
throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified publicIp is not associated to any VM"); | |
} else if (errorMessage.contains("specify a VM that is either running or stopped")) { | |
throw new EC2ServiceException(ClientError.IncorrectInstanceState, "Unable to attach. Specified instances is in an incorrect state"); | |
} else if (errorMessage.contains("specify a valid data volume")) { | |
throw new EC2ServiceException(ClientError.InvalidVolume_NotFound, "Specified volume doen't exist"); | |
} else if (errorMessage.contains("VolumeId is not in Ready state, but in state Allocated. Cannot take snapshot")) { | |
throw new EC2ServiceException(ClientError.IncorrectState, "Cannot take snapshot. Specified volume is not in the correct state"); | |
} else if (errorMessage.contains("Can't delete snapshot") && errorMessage.contains("it is not in BackedUp Status")) { | |
throw new EC2ServiceException(ClientError.IncorrectState, "Cannot delete snapshot. Specified snapshot is not in the correct state"); | |
} else if (errorMessage.contains("Invalid port range")) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: https://github.com/apache/cloudstack/blob/2f2efb095454025b51dafd08dcbb31e4e83d3cdb/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java#L2731