Stop catching RuntimeException. This made the errors in issue #1234 more confusing. And we should never catch RuntimeException unless we're about to crash.
--
MOS_MIGRATED_REVID=122031190
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
index f1d10bf..84d859f 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
@@ -35,10 +35,8 @@
return false;
}
- /**
- * Returns an exception which should be thrown instead of the original one.
- */
- protected final EvalException handleException(Exception original) {
+ /** Returns an exception which should be thrown instead of the original one. */
+ protected final EvalException maybeTransformException(EvalException original) {
// If there is already a non-empty stack trace, we only add this node iff it describes a
// new scope (e.g. FuncallExpression).
if (original instanceof EvalExceptionWithStackTrace) {
@@ -49,12 +47,11 @@
return real;
}
- // Returns the original exception if it cannot be attached to a stack trace.
- if (original instanceof EvalException && !((EvalException) original).canBeAddedToStackTrace()) {
- return (EvalException) original;
+ if (original.canBeAddedToStackTrace()) {
+ return new EvalExceptionWithStackTrace(original, this);
+ } else {
+ return original;
}
-
- return new EvalExceptionWithStackTrace(original, this);
}
@VisibleForTesting // productionVisibility = Visibility.PACKAGE_PRIVATE