001    /*
002     * Copyright 1999-2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */ 
016    
017    package org.apache.commons.workflow;
018    
019    
020    /**
021     * <p>A <strong>StepException</strong> is used to report problems encountered
022     * during the dynamic execution of a specific <code>Step</code>.
023     *
024     * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
025     * @author Craig R. McClanahan
026     */
027    
028    public class StepException extends WorkflowException {
029    
030    
031        // ----------------------------------------------------------- Constructors
032    
033    
034        /**
035         * Construct an empty StepException.
036         */
037        public StepException() {
038    
039            super();
040    
041        }
042    
043    
044        /**
045         * Construct an empty StepException occurring with the specified Step.
046         *
047         * @param step Step that caused this StepException
048         */
049        public StepException(Step step) {
050    
051            super();
052            this.step = step;
053    
054        }
055    
056    
057        /**
058         * Construct a StepException with the specified message.
059         *
060         * @param message Message associated with this exception
061         */
062        public StepException(String message) {
063    
064            super(message);
065    
066        }
067    
068    
069        /**
070         * Construct a StepException with the specified message occurring with
071         * the specified Step.
072         *
073         * @param message Message associated with this exception
074         * @param step Step that caused this StepException
075         */
076        public StepException(String message, Step step) {
077    
078            super(message);
079            this.step = step;
080    
081        }
082    
083    
084        /**
085         * Construct a StepException with the specified underlying cause.
086         * [JDK 1.4 compatible]
087         *
088         * @param cause Underlying root cause
089         */
090        public StepException(Throwable cause) {
091    
092            super();
093            this.cause = cause;
094    
095        }
096    
097    
098        /**
099         * 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    }