1 /***
2 * Copyright 2004 Steven Caswell
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 package com.mungoknotwise.sqlcli;
17
18 import org.apache.log4j.Logger;
19
20 /***
21 * Implementation of {@link ExceptionHandler} that writes exception details
22 * to the object's print streams.
23 *
24 * @author Steven Caswell
25 * @version $Id: PrintStreamedExceptionHandler.java,v 1.1.1.1 2004/07/28 01:12:38 mungoknotwise Exp $
26 */
27 public class PrintStreamedExceptionHandler
28 extends BasicPrintStreamed
29 implements ExceptionHandler
30 {
31
32 //----------------------------------------------------------------------------
33 // Static variables
34 //----------------------------------------------------------------------------
35
36 private static Logger logger = Logger.getLogger(PrintStreamedExceptionHandler.class);
37
38 //----------------------------------------------------------------------------
39 // Static methods
40 //----------------------------------------------------------------------------
41
42 //----------------------------------------------------------------------------
43 // Constants
44 //----------------------------------------------------------------------------
45
46 //----------------------------------------------------------------------------
47 // Instance variables
48 //----------------------------------------------------------------------------
49
50 //----------------------------------------------------------------------------
51 // Constructors
52 //----------------------------------------------------------------------------
53
54 /***
55 * Constructs a new instance of
56 * <code>PrintStreamedExceptionHandler</code>.
57 */
58 public PrintStreamedExceptionHandler()
59 {
60 }
61
62 //----------------------------------------------------------------------------
63 // Interface implementations
64 //----------------------------------------------------------------------------
65 //----------------------------------------------------------------------------
66 // Implementation of interface ExceptionHandler
67 //----------------------------------------------------------------------------
68
69 /***
70 * {@inheritDoc}
71 */
72 public void handleException(final Exception e)
73 {
74 Throwable cause = e;
75 while(cause.getCause() != null)
76 {
77 cause = cause.getCause();
78 }
79 this.println("");
80 this.println(cause.getMessage());
81 this.println("");
82 }
83
84 //----------------------------------------------------------------------------
85 // Extends overrides
86 //----------------------------------------------------------------------------
87 //----------------------------------------------------------------------------
88 // Override of class Class1
89 //----------------------------------------------------------------------------
90
91
92 //----------------------------------------------------------------------------
93 // Public methods exposed by this class
94 //----------------------------------------------------------------------------
95
96 //----------------------------------------------------------------------------
97 // Protected abstract methods
98 //----------------------------------------------------------------------------
99
100 //----------------------------------------------------------------------------
101 // Protected methods for use by subclasses
102 //----------------------------------------------------------------------------
103
104 //----------------------------------------------------------------------------
105 // Other methods
106 //----------------------------------------------------------------------------
107
108 //----------------------------------------------------------------------------
109 // Member classes
110 //----------------------------------------------------------------------------
111
112 }