X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=base%2Fruntime%2Forg.argeo.util%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2FArgeoException.java;h=9cf91866717f9143c282478420b360ce4c6d3540;hb=3a3d316af102ba410d1d9e6de349d0c8f7ac044f;hp=343b6c947fad8d05d42410650ca75af0dea67587;hpb=5e65b1c0f228622aebfe03b23706cb6a02a5a96a;p=lgpl%2Fargeo-commons.git diff --git a/base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoException.java b/base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoException.java index 343b6c947..9cf918667 100644 --- a/base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoException.java +++ b/base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoException.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2012 Mathieu Baudier + * Copyright (C) 2007-2012 Argeo GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,21 @@ public class ArgeoException extends RuntimeException { super(message, e); } - /** @deprecated use {@link #ArgeoException(String, Throwable)} instead. */ - @Deprecated - public ArgeoException(Throwable cause) { - super(cause); + /** + * Chain the messages of all causes (one per line, starts with a line + * return) without all the stack + */ + public static String chainCausesMessages(Throwable t) { + StringBuffer buf = new StringBuffer(); + chainCauseMessage(buf, t); + return buf.toString(); } + /** Recursive chaining of messages */ + private static void chainCauseMessage(StringBuffer buf, Throwable t) { + buf.append('\n').append(' ').append(t.getClass().getCanonicalName()) + .append(": ").append(t.getMessage()); + if (t.getCause() != null) + chainCauseMessage(buf, t.getCause()); + } }