001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.pipeline; 019 020 /** 021 * Exception wrapper class for exceptions that occur while processing a stage. 022 */ 023 public class StageException extends java.lang.Exception { 024 /** 025 * 026 */ 027 private static final long serialVersionUID = -7427836310660170668L; 028 029 //Stage within which the error occurred 030 private Stage source; 031 032 /** 033 * Creates a new instance of <code>StageException</code> without detail message. 034 * @param source the stage that was the source of the exception 035 */ 036 public StageException(Stage source) { 037 this.source = source; 038 } 039 040 041 /** 042 * Constructs an instance of <code>StageException</code> with the specified detail message. 043 * @param source the stage that was the source of the exception 044 * @param msg the detail message. 045 */ 046 public StageException(Stage source, String msg) { 047 super(msg); 048 this.source = source; 049 } 050 051 052 /** 053 * Constructs an instance of <code>StageException</code> with the specified detail message and cause 054 * @param source the stage where the error occurred 055 * @param msg the detail message. 056 * @param cause Throwable that caused this exception. 057 */ 058 public StageException(Stage source, Throwable cause) { 059 super(cause); 060 this.source = source; 061 } 062 063 064 /** 065 * Constructs an instance of <code>StageException</code> with the specified detail message and cause 066 * @param source the stage where the error occurred 067 * @param msg the detail message. 068 * @param cause Throwable that caused this exception. 069 */ 070 public StageException(Stage source, String msg, Throwable cause) { 071 super(msg, cause); 072 this.source = source; 073 } 074 075 076 /** 077 * Returns a reference to the Stage object where the exception occurred. 078 * @return a reference to the Stage object where the exception occurred. 079 */ 080 public Stage getSource() { 081 return this.source; 082 } 083 }