blob: 765d9eede19f31d048b9d12632e7395ce30b256d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/*
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
*/
package org.apache.fop.apps;
import org.xml.sax.SAXException;
/**
* Exception thrown when FOP has a problem
*/
public class FOPException extends Exception {
private static final String EXCEPTION_SEPARATOR = "\n---------\n";
private Throwable _exception;
/**
* create a new FOP Exception
*
* @param message descriptive message
*/
public FOPException(String message) {
super(message);
}
public FOPException(Throwable e) {
super(e.getMessage());
setException(e);
}
public FOPException(String message, Throwable e) {
super(message);
setException(e);
}
protected void setException(Throwable t)
{
_exception = t;
}
public Throwable getException()
{
return _exception;
}
protected Throwable getRootException()
{
Throwable result = _exception;
if (result instanceof SAXException) {
result = ((SAXException)result).getException();
}
if (result instanceof java.lang.reflect.InvocationTargetException) {
result = ((java.lang.reflect.InvocationTargetException)result).getTargetException();
}
if (result != _exception) {
return result;
}
return null;
}
public void printStackTrace()
{
synchronized (System.err) {
super.printStackTrace();
if (_exception != null) {
System.err.println(EXCEPTION_SEPARATOR);
_exception.printStackTrace();
}
if (getRootException() != null) {
System.err.println(EXCEPTION_SEPARATOR);
getRootException().printStackTrace();
}
}
}
public void printStackTrace(java.io.PrintStream stream)
{
synchronized (stream) {
super.printStackTrace(stream);
if (_exception != null) {
stream.println(EXCEPTION_SEPARATOR);
_exception.printStackTrace(stream);
}
if (getRootException() != null) {
System.err.println(EXCEPTION_SEPARATOR);
getRootException().printStackTrace(stream);
}
}
}
public void printStackTrace(java.io.PrintWriter writer)
{
synchronized (writer) {
super.printStackTrace(writer);
if (_exception != null) {
writer.println(EXCEPTION_SEPARATOR);
_exception.printStackTrace(writer);
}
if (getRootException() != null) {
System.err.println(EXCEPTION_SEPARATOR);
getRootException().printStackTrace(writer);
}
}
}
}
|