View Javadoc

1   /*$Id: AggregateException.java,v 1.1 2005/04/01 10:24:19 nw Exp $
2    * Created on 01-Apr-2005
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.jes.jobscheduler.dispatcher;
12  
13  import java.io.PrintStream;
14  import java.io.PrintWriter;
15  
16  /*** An exception that aggregates a set of causal exceptions.
17   * @author Noel Winstanley nw@jb.man.ac.uk 01-Apr-2005
18   *
19   */
20  public class AggregateException  extends Exception {
21  
22      public String getLocalizedMessage() {
23          return this.getMessage();
24      }
25      public String getMessage() {
26          StringBuffer msg = new StringBuffer();
27          msg.append("Multiple Causes:\n");
28          for (int i = 0; i < causes.length; i++) {
29              msg.append(causes[i].getMessage());
30              msg.append("\n");
31          }
32          return msg.toString();
33      }
34  
35      public void printStackTrace(PrintStream s) {
36          //synchronized(s) {
37              s.println(this);
38              for (int i = 0; i < causes.length; i++) {
39                  causes[i].printStackTrace(s);
40              }
41          //}
42      }
43      public void printStackTrace(PrintWriter s) {
44          //synchronized(s) {
45          s.println(this);
46          for (int i = 0; i < causes.length; i++) {
47              causes[i].printStackTrace(s);
48          }
49      //}
50      }
51      /*** Construct a new AggregateException
52       * 
53       */
54      public AggregateException(Throwable[] causes) {
55          super();
56          this.causes = causes;
57      }
58      
59      protected final Throwable[] causes;
60  
61  }
62  
63  
64  /* 
65  $Log: AggregateException.java,v $
66  Revision 1.1  2005/04/01 10:24:19  nw
67  improved logging of cea connect failures
68   
69  */