either log or throw, but not both

This commit is contained in:
Jonathan Shook 2020-07-16 09:20:24 -05:00
parent 0230686a23
commit 1fe38b4394
10 changed files with 6 additions and 12 deletions

View File

@ -46,7 +46,7 @@ public class UnsettableValuesBinder implements ValuesArrayBinder<PreparedStateme
return boundStmt;
} catch (Exception e) {
String typNam = (objects[i]==null ? "NULL" : objects[i].getClass().getCanonicalName());
logger.error("Error binding column " + preparedStatement.getVariables().asList().get(i).getName() + " with class " + typNam + ": " + e.getMessage(), e);
logger.error("Error binding column " + preparedStatement.getVariables().asList().get(i).getName() + " with class " + typNam, e);
throw e;
// StringBuilder sb = new StringBuilder();
// sb.append("Error binding objects to prepared statement directly, falling back to diagnostic binding layer:");

View File

@ -154,8 +154,7 @@ public class CQLSessionCache implements Shutdownable {
builder = clusterEval.eval();
logger.info("successfully applied:" + clusteropts.get());
} catch (Exception e) {
logger.error("Unable to evaluate: " + clusteropts.get() + " in script context:" + e.getMessage());
throw e;
throw new RuntimeException("Unable to evaluate: " + clusteropts.get() + " in script context:",e);
}
}

View File

@ -42,7 +42,6 @@ public class YamlCQLStatementLoader {
data = xform.apply(data);
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transform to input", e);
logger.error(t.getMessage(), t);
throw t;
}
}

View File

@ -38,7 +38,7 @@ public class Save implements RowCycleOperator {
List<ColumnDefinitions.Definition> definitions = row.getColumnDefinitions().asList();
logger.error("Unable to save '" + Arrays.toString(varnames) + "' from " +
definitions.stream().map(ColumnDefinitions.Definition::getName)
.collect(Collectors.joining(",","[","]")) + ": " + e.getMessage(),e);
.collect(Collectors.joining(",","[","]")) + ": ",e);
throw e;
}
return 0;

View File

@ -58,7 +58,7 @@ public class UnsettableValuesBinder implements ValuesArrayBinder<PreparedStateme
List<ColumnDefinition> cdefs = new ArrayList<>();
preparedStatement.getVariableDefinitions().forEach(cdefs::add);
logger.error("Error binding column " + cdefs.get(i).getName() + " with class " + typNam + ": " + e.getMessage(), e);
logger.error("Error binding column " + cdefs.get(i).getName() + " with class " + typNam, e);
throw e;
// StringBuilder sb = new StringBuilder();
// sb.append("Error binding objects to prepared statement directly, falling back to diagnostic binding layer:");

View File

@ -38,7 +38,6 @@ public class YamlCQLStatementLoader {
data = xform.apply(data);
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transform to input", e);
logger.error(t.getMessage(), t);
throw t;
}
}

View File

@ -28,7 +28,6 @@ public class RawStmtsLoader {
}
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string applyTransforms to input", e);
if (logger != null) logger.error(t.getMessage(), t);
throw t;
}
@ -76,7 +75,6 @@ public class RawStmtsLoader {
data = xform.apply(data);
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string applyTransforms to input", e);
if (logger != null) logger.error(t.getMessage(), t);
throw t;
}
}

View File

@ -45,7 +45,6 @@ public class HistoStatsCSVWriter {
PrintStream writer = new PrintStream(logfile);
return writer;
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}

View File

@ -102,7 +102,7 @@ public class PathFinder {
}
return Optional.empty();
} catch (Exception e) {
logger.trace("Error while looking in classpath for " + e.getMessage(), e);
logger.trace("Error while looking in classpath for " + candidatePath, e);
return Optional.empty();
}
}

View File

@ -188,7 +188,7 @@ public class ValuesCheckerCoordinator implements Callable<RunData> {
lock.lock();
goTime.signalAll();
} catch (Exception e) {
logger.error("Error while signaling threads: " + e.getMessage(), e);
logger.error("Error while signaling threads:", e);
throw new RuntimeException(e);
} finally {
lock.unlock();