01: /*
02: * Copyright 2004-2006 Fouad HAMDI.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.csvbeans.builders;
17:
18: import java.io.PrintStream;
19: import java.io.PrintWriter;
20:
21: import org.csvbeans.CSVBeansException;
22:
23: /**
24: * Exception class thrown when generating CSV files.
25: *
26: * @author Fouad Hamdi
27: * @since 0.5
28: */
29: public class GenerationException extends CSVBeansException {
30: private final static long serialVersionUID = 1L;
31:
32: /**
33: * Invalid object.
34: */
35: private Object invalidObject;
36:
37: /**
38: * Constructor.
39: */
40: public GenerationException(String s, Object invalidObject) {
41: this (s, invalidObject, null);
42: }
43:
44: /**
45: * Constructor.
46: */
47: public GenerationException(String s, Object invalidObject,
48: Throwable t) {
49: super (null, s, t);
50: this .invalidObject = invalidObject;
51: }
52:
53: /**
54: * @return Returns the invalidObject.
55: */
56: public Object getInvalidObject() {
57: return invalidObject;
58: }
59:
60: /**
61: * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
62: */
63: public void printStackTrace(PrintWriter s) {
64: if (invalidObject != null) {
65: s.write("Objet invalide: " + invalidObject.toString());
66: }
67: super .printStackTrace(s);
68: }
69:
70: /**
71: * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
72: */
73: public void printStackTrace(PrintStream s) {
74: if (invalidObject != null) {
75: s.println("Objet invalide: " + invalidObject.toString());
76: }
77: super.printStackTrace(s);
78: }
79: }
|