aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-09-02 14:04:33 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-09-02 14:33:19 +0000
commit6a663390e5247c8619991ca763a9496839d61f8b (patch)
treea1ddb3c8c161efc7f9882ca71b0bd96cfcf53957 /src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
parente899fc3054d25cf5d8fd06d585dd05737944e7cd (diff)
When a Skylark macro creates a native rule, it also sets the following rule attributes: generator_{function, name, location}
-- MOS_MIGRATED_REVID=102139196
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
index 686ccab083..82ca835ccd 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
@@ -232,6 +232,7 @@ public class EvalExceptionWithStackTrace extends EvalException {
* <p> If the exception itself does not have a message, a new message is constructed from the
* exception's class name.
* For example, an IllegalArgumentException will lead to "Illegal Argument".
+ * Additionally, the location in the Java code will be added, if applicable,
*/
private static String getNonEmptyMessage(Exception original) {
Preconditions.checkNotNull(original);
@@ -252,6 +253,18 @@ public class EvalExceptionWithStackTrace extends EvalException {
first = false;
}
+ java.lang.StackTraceElement[] trace = original.getStackTrace();
+ if (trace.length > 0) {
+ builder.append(String.format(": %s.%s() in %s:%d", getShortClassName(trace[0]),
+ trace[0].getMethodName(), trace[0].getFileName(), trace[0].getLineNumber()));
+ }
+
return builder.toString();
}
+
+ private static String getShortClassName(java.lang.StackTraceElement element) {
+ String name = element.getClassName();
+ int pos = name.lastIndexOf('.');
+ return (pos < 0) ? name : name.substring(pos + 1);
+ }
}