Skip to content

Commit

Permalink
Improved CLI exceptions
Browse files Browse the repository at this point in the history
patch by satishbabu; reviewed by xedin for CASSANDRA-3312

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.8@1179164 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
xedin committed Oct 5, 2011
1 parent 0cfcd72 commit 5c26768
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Expand Up @@ -27,7 +27,7 @@
* Allow using number as DC name when creating keyspace in CQL (CASSANDRA-3239)
* Force flush of system table after updating/removing a token (CASSANDRA-3243)
* Make Pig storage handle implements LoadMetadata (CASSANDRA-2777)

* Improved CLI exceptions (CASSANDRA-3312)

0.8.6
* revert CASSANDRA-2388
Expand Down
46 changes: 22 additions & 24 deletions src/java/org/apache/cassandra/cli/CliClient.java
Expand Up @@ -301,9 +301,7 @@ public void executeCLIStatement(String statement)
}
catch (SchemaDisagreementException e)
{
RuntimeException rtEx = new RuntimeException("schema does not match across nodes, (try again later).");
rtEx.initCause(e);
throw new RuntimeException();
throw new RuntimeException("schema does not match across nodes, (try again later).", e);
}
catch (Exception e)
{
Expand Down Expand Up @@ -552,7 +550,7 @@ private AbstractType getFormatType(String compareWith)
{
StringBuilder errorMessage = new StringBuilder("Unknown comparator '" + compareWith + "'. ");
errorMessage.append("Available functions: ");
throw new RuntimeException(errorMessage.append(Function.getFunctionNames()).toString());
throw new RuntimeException(errorMessage.append(Function.getFunctionNames()).toString(), e);
}
}

Expand Down Expand Up @@ -778,7 +776,7 @@ private void executeGetWithConditions(Tree statement)
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -807,11 +805,11 @@ private void executeGetWithConditions(Tree statement)
}
catch (InvalidRequestException e)
{
throw new RuntimeException(e.getWhy());
throw new RuntimeException(e);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -894,7 +892,7 @@ else if (columnSpecCnt == 1)
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -961,7 +959,7 @@ else if (columnSpecCnt == 2)
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -1004,11 +1002,11 @@ private void executeAddKeySpace(Tree statement)
}
catch (InvalidRequestException e)
{
throw new RuntimeException(e.getWhy());
throw new RuntimeException(e);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}
}

Expand All @@ -1034,11 +1032,11 @@ private void executeAddColumnFamily(Tree statement)
}
catch (InvalidRequestException e)
{
throw new RuntimeException(e.getWhy());
throw new RuntimeException(e);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}
}

Expand All @@ -1065,11 +1063,11 @@ private void executeUpdateKeySpace(Tree statement)
}
catch (InvalidRequestException e)
{
throw new RuntimeException(e.getWhy());
throw new RuntimeException(e);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -1099,11 +1097,11 @@ private void executeUpdateColumnFamily(Tree statement)
}
catch (InvalidRequestException e)
{
throw new RuntimeException(e.getWhy());
throw new RuntimeException(e);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -1163,7 +1161,7 @@ private KsDef updateKsDefAttributes(Tree statement, KsDef ksDefToUpdate)
}
catch (UnknownHostException e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}

ksDef.setStrategy_options(options);
Expand Down Expand Up @@ -2180,7 +2178,7 @@ else if (metaKey.equals("index_name"))
}
catch (TException e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}

columnDefinitions.add(columnDefinition);
Expand Down Expand Up @@ -2211,7 +2209,7 @@ private IndexType getIndexTypeFromString(String indexTypeAsString)
}
catch (IllegalArgumentException ie)
{
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.");
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.", ie);
}
}

Expand Down Expand Up @@ -2240,7 +2238,7 @@ private ByteBuffer getBytesAccordingToType(String object, AbstractType comparato
}
catch (MarshalException e)
{
throw new RuntimeException(e.toString());
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -2355,7 +2353,7 @@ private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamily
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
throw new RuntimeException(e);
}
}
}
Expand Down Expand Up @@ -2491,7 +2489,7 @@ else if (validator instanceof BytesType)
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e);
}
}

Expand All @@ -2512,7 +2510,7 @@ public static AbstractType getTypeByFunction(String functionName)
{
StringBuilder errorMessage = new StringBuilder("Function '" + functionName + "' not found. ");
errorMessage.append("Available functions: ");
throw new RuntimeException(errorMessage.append(Function.getFunctionNames()).toString());
throw new RuntimeException(errorMessage.append(Function.getFunctionNames()).toString(), e);
}

return function.getValidator();
Expand Down

0 comments on commit 5c26768

Please sign in to comment.