1 16 17 package org.apache.avalon.fortress.util; 18 19 import org.apache.avalon.framework.CascadingException; 20 21 24 public final class CompositeException extends CascadingException 25 { 26 private final Exception [] m_ex; 27 private final String m_message; 28 29 public CompositeException( final Exception [] ex ) 30 { 31 this( ex, null ); 32 } 33 34 public CompositeException( final Exception [] ex, final String message ) 35 { 36 super( message, null ); 37 m_ex = ex; 38 if ( ex == null || ex.length < 1 ) 39 { 40 throw new IllegalArgumentException ( "you must specify a contained exception!" ); 41 } 42 if ( message == null ) 43 { 44 final StringBuffer msg = new StringBuffer (); 45 for ( int i = 0; i < ex.length; i++ ) 46 { 47 if (i > 0) msg.append('\n'); 48 msg.append( ex[i].getMessage() ); 49 } 50 m_message = msg.toString(); 51 } 52 else 53 m_message = message; 54 } 55 56 public String getMessage() 57 { 58 return m_message; 59 } 60 61 public Exception [] getExceptions() 62 { 63 return m_ex; 64 } 65 } 66 | Popular Tags |