From 81e5eea8b40f0be215b84757cbf8b2f2e35bfe83 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 16 Nov 2004 08:37:41 +0000 Subject: [PATCH] Try to provide more information on an exception occuring in Kaffe git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277039 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/zip/ZipEntry.java | 30 +++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/zip/ZipEntry.java b/src/main/org/apache/tools/zip/ZipEntry.java index cea728230..e18f33bc7 100644 --- a/src/main/org/apache/tools/zip/ZipEntry.java +++ b/src/main/org/apache/tools/zip/ZipEntry.java @@ -426,13 +426,17 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { setCompressedSizeMethod.invoke(ze, (Object[])s); } catch (InvocationTargetException ite) { Throwable nested = ite.getTargetException(); + String msg = getDisplayableMessage(nested); + if (msg == null) { + msg = getDisplayableMessage(ite); + } + throw new RuntimeException("InvocationTargetException setting the " + + "compressed size of " + ze + ": " + + msg); + } catch (Exception other) { throw new RuntimeException("Exception setting the compressed size " + "of " + ze + ": " - + nested.getMessage()); - } catch (Throwable other) { - throw new RuntimeException("Exception setting the compressed size " - + "of " + ze + ": " - + other.getMessage()); + + getDisplayableMessage(other)); } } @@ -455,4 +459,20 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { } } + /** + * try to get as much single-line information out of the exception + * as possible. + */ + private static String getDisplayableMessage(Throwable e) { + String msg = null; + if (e != null) { + if (e.getMessage() != null) { + msg = e.getClass().getName() + ": " + e.getMessage(); + } else { + msg = e.getClass().getName(); + } + } + return msg; + } + }