View Javadoc

1   /*
2    * All Rights Reserved.
3    * Copyright (C) 1999-2005 Tsukuba Bunko.
4    *
5    * Licensed under the BSD License ("the License"); you may not use
6    * this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    *       http://www.tsukuba-bunko.org/licenses/LICENSE.txt
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   *
17   * $Id: SaveFailureException.java,v 1.2 2005/07/23 19:06:28 ppoi Exp $
18   */
19  package tsukuba_bunko.peko.session;
20  
21  import	java.io.PrintStream;
22  import	java.io.PrintWriter;
23  
24  
25  /***
26   * セーブが失敗したことを通知する例外です。
27   * @author	$Author: ppoi $
28   * @version	$Revision: 1.2 $
29   */
30  public class SaveFailureException	extends Exception	{
31  
32  	/***
33  	 * serial version UID
34  	 */
35  	private static final long	serialVersionUID	= 1764861384183120318L;
36  
37  	/***
38  	 * 基になる例外オブジェクト
39  	 */
40  	private Throwable	_base = null;
41  
42  
43  	/***
44  	 * <code>SaveFailureException</code> のインスタンスを作成します。
45  	 */
46  	public SaveFailureException()
47  	{
48  		super();
49  	}
50  
51  	/***
52  	 * <code>SaveFailureException</code> のインスタンスを作成します。
53  	 * @param	message	エラーメッセージ
54  	 */
55  	public SaveFailureException( String message )
56  	{
57  		super( message );
58  	}
59  
60  	/***
61  	 * <code>SaveFailureException</code> のインスタンスを作成します。
62  	 * @param	e	基になる例外オブジェクト
63  	 */
64  	public SaveFailureException( Throwable e )
65  	{
66  		super( e.getMessage() );
67  		_base = e;
68  	}
69  
70  	/***
71  	 * <code>SaveFailureException</code> のインスタンスを作成します。
72  	 * @param	message	エラーメッセージ
73  	 * @param	e	基になる例外オブジェクト
74  	 */
75  	public SaveFailureException( String message, Throwable e )
76  	{
77  		super( message );
78  		_base = e;
79  	}
80  
81  
82  //
83  //	Throwable の実装
84  //
85  	public void printStackTrace()
86  	{
87  		super.printStackTrace();
88  		if( _base != null )	{
89  			System.err.println( "source exception: " + _base.getClass().getName() );
90  			_base.printStackTrace();
91  		}
92  	}
93  
94  	public void printStackTrace( PrintStream ps )
95  	{
96  		super.printStackTrace( ps );
97  		if( _base != null )	{
98  			ps.println( "source exception: " + _base.getClass().getName() );
99  			_base.printStackTrace( ps );
100 		}
101 	}
102 
103 	public void printStackTrace( PrintWriter pw )
104 	{
105 		super.printStackTrace();
106 		if( _base != null )	{
107 			pw.println( "source exception: " + _base.getClass().getName() );
108 			_base.printStackTrace( pw );
109 		}
110 	}
111 }