Browse Source

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
master
Stefan Bodewig 20 years ago
parent
commit
81e5eea8b4
1 changed files with 25 additions and 5 deletions
  1. +25
    -5
      src/main/org/apache/tools/zip/ZipEntry.java

+ 25
- 5
src/main/org/apache/tools/zip/ZipEntry.java View File

@@ -426,13 +426,17 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
setCompressedSizeMethod.invoke(ze, (Object[])s); setCompressedSizeMethod.invoke(ze, (Object[])s);
} catch (InvocationTargetException ite) { } catch (InvocationTargetException ite) {
Throwable nested = ite.getTargetException(); 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 " throw new RuntimeException("Exception setting the compressed size "
+ "of " + ze + ": " + "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;
}

} }

Loading…
Cancel
Save