From 99529fd6c5e0d622048fe2ea34af150b7a1f09ff Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 28 Oct 2008 14:32:23 +0000 Subject: [PATCH] At least try to log the real reason of an error. PR 26086 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@708584 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ src/main/org/apache/tools/ant/Main.java | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index ac34cb08b..3cd29d516 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -278,6 +278,10 @@ Fixed bugs: some setups. Bugzilla Report 46063. + * if an error occurs while logging the buildFinished event, the + original error is now logged to System.err. + Bugzilla Report 25086. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 5a53f4052..97a1e9046 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -792,7 +792,21 @@ public class Main implements AntMain { throw e; } finally { if (!projectHelp) { - project.fireBuildFinished(error); + try { + project.fireBuildFinished(error); + } catch (Throwable t) { + // yes, I know it is bad style to catch Throwable, + // but if we don't, we lose valuable information + System.err.println("Caught an exception while logging the" + + " end of the build. Exception was:"); + t.printStackTrace(); + if (error != null) { + System.err.println("There has been an error prior to" + + " that:"); + error.printStackTrace(); + } + throw new BuildException(t); + } } else if (error != null) { project.log(error.toString(), Project.MSG_ERR); }