diff --git a/CHANGES.txt b/CHANGES.txt index 9302c718a7d3..5322d2e27bc4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java index f1495ccc23ab..2c127c42a524 100644 --- a/src/java/org/apache/cassandra/cli/CliClient.java +++ b/src/java/org/apache/cassandra/cli/CliClient.java @@ -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) { @@ -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); } } @@ -778,7 +776,7 @@ private void executeGetWithConditions(Tree statement) } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e); } } @@ -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); } } @@ -894,7 +892,7 @@ else if (columnSpecCnt == 1) } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e); } } @@ -961,7 +959,7 @@ else if (columnSpecCnt == 2) } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); @@ -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); @@ -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); } } @@ -2240,7 +2238,7 @@ private ByteBuffer getBytesAccordingToType(String object, AbstractType comparato } catch (MarshalException e) { - throw new RuntimeException(e.toString()); + throw new RuntimeException(e); } } @@ -2355,7 +2353,7 @@ private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamily } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); + throw new RuntimeException(e); } } } @@ -2491,7 +2489,7 @@ else if (validator instanceof BytesType) } catch (Exception e) { - throw new RuntimeException(e.getMessage()); + throw new RuntimeException(e); } } @@ -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();