]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoException.java
Add dep folder
[lgpl/argeo-commons.git] / base / runtime / org.argeo.util / src / main / java / org / argeo / ArgeoException.java
index 343b6c947fad8d05d42410650ca75af0dea67587..9cf91866717f9143c282478420b360ce4c6d3540 100644 (file)
@@ -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, <b>starts with a line
+        * return</b>) 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());
+       }
 }