From 04024a63d1ca09647b461c38fd398e072e64c150 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Sat, 3 Feb 2001 14:06:32 +0000 Subject: [PATCH] Change buildException to always print nested exceptions when printing its stack trace. Removed the equivalent code from DefaultLogger. Submitted by: Jesse Glick git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268565 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/BuildException.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/BuildException.java b/src/main/org/apache/tools/ant/BuildException.java index af823d1ea..efbda7476 100644 --- a/src/main/org/apache/tools/ant/BuildException.java +++ b/src/main/org/apache/tools/ant/BuildException.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,6 +53,9 @@ */ package org.apache.tools.ant; + +import java.io.*; + /** * Signals an error condition during a build. * @@ -162,4 +165,29 @@ public class BuildException extends RuntimeException { public Location getLocation() { return location; } + + // Override stack trace methods to show original cause: + public void printStackTrace() { + printStackTrace(System.err); + } + + public void printStackTrace(PrintStream ps) { + synchronized (ps) { + ps.println(this); + if (cause != null) { + ps.println("--- Nested Exception ---"); + cause.printStackTrace(ps); + } + } + } + + public void printStackTrace(PrintWriter pw) { + synchronized (pw) { + pw.println(this); + if (cause != null) { + pw.println("--- Nested Exception ---"); + cause.printStackTrace(pw); + } + } + } }