Browse Source

#43398 revisited: display full stack traces for non-BuildException's, even inside <ant>.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@803739 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 16 years ago
parent
commit
78f88a7c4a
3 changed files with 18 additions and 6 deletions
  1. +4
    -0
      WHATSNEW
  2. +7
    -1
      src/main/org/apache/tools/ant/DefaultLogger.java
  3. +7
    -5
      src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java

+ 4
- 0
WHATSNEW View File

@@ -148,6 +148,10 @@ Changes that could break older environments:
Fixed bugs:
-----------

* The default logger was failing to print complete stack traces for exceptions
other than BuildException when inside <ant> or <antcall>, thus omitting often
important diagnostic information. Bugzilla 43398 (continued).

* Better handling of package-info.class. Bugzilla Report 43114.

* RPM task needed an inserted space between the define and the value.


+ 7
- 1
src/main/org/apache/tools/ant/DefaultLogger.java View File

@@ -133,7 +133,13 @@ public class DefaultLogger implements BuildLogger {
static void throwableMessage(StringBuffer m, Throwable error, boolean verbose) {
while (error instanceof BuildException) { // #43398
Throwable cause = ((BuildException) error).getCause();
if (cause != null && cause.toString().equals(error.getMessage())) {
if (cause == null) {
break;
}
String msg1 = error.toString();
String msg2 = cause.toString();
if (msg1.endsWith(msg2)) {
m.append(msg1.substring(0, msg1.length() - msg2.length()));
error = cause;
} else {
break;


+ 7
- 5
src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java View File

@@ -56,19 +56,21 @@ public class DefaultLoggerTest extends TestCase {
w.println(" at p.C.m");
}
};
be = new BuildException(x);
assertEquals(
"problem\n" +
" at p.C.m\n",
msg(x, false));
be = new BuildException(x, new Location("build.xml", 1, 0));
assertEquals(
"build.xml:1: problem\n" +
" at p.C.m\n",
msg(be, false));
/* XXX still broken:
be = ProjectHelper.addLocationToBuildException(be, new Location("build.xml", 1, 0));
be = ProjectHelper.addLocationToBuildException(be, new Location("build.xml", 2, 0));
assertEquals(
"The following error occurred while executing this line:\n" +
"build.xml:2: The following error occurred while executing this line:\n" +
"build.xml:1: problem\n" +
" at p.C.m\n",
msg(be, false));
*/
}

}

Loading…
Cancel
Save