View Javadoc

1   /*
2    * Copyright 1999-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16  
17  package org.apache.commons.workflow;
18  
19  
20  /**
21   * <p>A <strong>StepException</strong> is used to report problems encountered
22   * during the dynamic execution of a specific <code>Step</code>.
23   *
24   * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
25   * @author Craig R. McClanahan
26   */
27  
28  public class StepException extends WorkflowException {
29  
30  
31      // ----------------------------------------------------------- Constructors
32  
33  
34      /**
35       * Construct an empty StepException.
36       */
37      public StepException() {
38  
39          super();
40  
41      }
42  
43  
44      /**
45       * Construct an empty StepException occurring with the specified Step.
46       *
47       * @param step Step that caused this StepException
48       */
49      public StepException(Step step) {
50  
51          super();
52          this.step = step;
53  
54      }
55  
56  
57      /**
58       * Construct a StepException with the specified message.
59       *
60       * @param message Message associated with this exception
61       */
62      public StepException(String message) {
63  
64          super(message);
65  
66      }
67  
68  
69      /**
70       * Construct a StepException with the specified message occurring with
71       * the specified Step.
72       *
73       * @param message Message associated with this exception
74       * @param step Step that caused this StepException
75       */
76      public StepException(String message, Step step) {
77  
78          super(message);
79          this.step = step;
80  
81      }
82  
83  
84      /**
85       * Construct a StepException with the specified underlying cause.
86       * [JDK 1.4 compatible]
87       *
88       * @param cause Underlying root cause
89       */
90      public StepException(Throwable cause) {
91  
92          super();
93          this.cause = cause;
94  
95      }
96  
97  
98      /**
99       * Construct a StepException with the specified underlying cause,
100      * occurring in the specified Step.
101      * [JDK 1.4 compatible]
102      *
103      * @param cause Underlying root cause
104      * @param step Step that caused this StepException
105      */
106     public StepException(Throwable cause, Step step) {
107 
108         super();
109         this.cause = cause;
110         this.step = step;
111 
112     }
113 
114 
115     /**
116      * Construct a StepException with the specified message and
117      * underlying cause.  [JDK 1.4 compatbile]
118      *
119      * @param message Message associated with this exception
120      * @param cause Underlying root cause
121      */
122     public StepException(String message, Throwable cause) {
123 
124         super(message);
125         this.cause = cause;
126 
127     }
128 
129 
130     /**
131      * Construct a StepException with the specified message and
132      * underlying cause, occurring in the specified Step.  [JDK 1.4 compatbile]
133      *
134      * @param message Message associated with this exception
135      * @param cause Underlying root cause
136      * @param step Step that caused this StepException
137      */
138     public StepException(String message, Throwable cause, Step step) {
139 
140         super(message);
141         this.cause = cause;
142         this.step = step;
143 
144     }
145 
146 
147     // ------------------------------------------------------------- Properties
148 
149 
150     /**
151      * The Step that was being executed when the problem occurred.
152      */
153     protected Step step = null;
154 
155     public Step getStep() {
156         return (this.step);
157     }
158 
159 
160     // --------------------------------------------------------- Public Methods
161 
162 
163     /**
164      * Render a printable version of this exception.
165      */
166     public String toString() {
167 
168         StringBuffer sb = new StringBuffer("StepException[");
169         sb.append("message=");
170         sb.append(getMessage());
171         if (step != null) {
172             sb.append(", step=");
173             sb.append(step);
174         }
175         if (cause != null) {
176             sb.append(", cause=");
177             sb.append(cause);
178         }
179         sb.append("]");
180         return (sb.toString());
181 
182     }
183 
184 
185 }