| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.commons.jelly; |
| 18 |
|
|
| 19 |
|
import java.io.PrintStream; |
| 20 |
|
import java.io.PrintWriter; |
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
public class JellyException extends Exception implements LocationAware { |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
private Throwable cause; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
private String fileName; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
private String elementName; |
| 39 |
|
|
| 40 |
|
|
| 41 |
481 |
private int lineNumber = -1; |
| 42 |
|
|
| 43 |
|
|
| 44 |
481 |
private int columnNumber = -1; |
| 45 |
|
|
| 46 |
0 |
public JellyException() { |
| 47 |
0 |
} |
| 48 |
|
|
| 49 |
|
public JellyException(String message) { |
| 50 |
403 |
super(message); |
| 51 |
403 |
} |
| 52 |
|
|
| 53 |
|
public JellyException(String message, Throwable cause) { |
| 54 |
78 |
super(message); |
| 55 |
78 |
this.cause = cause; |
| 56 |
78 |
} |
| 57 |
|
|
| 58 |
|
public JellyException(Throwable cause) { |
| 59 |
0 |
super(cause.getLocalizedMessage()); |
| 60 |
0 |
this.cause = cause; |
| 61 |
0 |
} |
| 62 |
|
|
| 63 |
|
public JellyException(Throwable cause, String fileName, String elementName, int columnNumber, class="keyword">int lineNumber) { |
| 64 |
0 |
this(cause.getLocalizedMessage(), cause, fileName, elementName, columnNumber, lineNumber); |
| 65 |
0 |
} |
| 66 |
|
|
| 67 |
|
public JellyException(String reason, Throwable cause, String fileName, String elementName, int columnNumber, class="keyword">int lineNumber) { |
| 68 |
0 |
super( (reason==null?cause.getClass().getName():reason) ); |
| 69 |
0 |
this.cause = cause; |
| 70 |
0 |
this.fileName = fileName; |
| 71 |
0 |
this.elementName = elementName; |
| 72 |
0 |
this.columnNumber = columnNumber; |
| 73 |
0 |
this.lineNumber = lineNumber; |
| 74 |
0 |
} |
| 75 |
|
|
| 76 |
|
public JellyException(String reason, String fileName, String elementName, int columnNumber, class="keyword">int lineNumber) { |
| 77 |
0 |
super(reason); |
| 78 |
0 |
this.fileName = fileName; |
| 79 |
0 |
this.elementName = elementName; |
| 80 |
0 |
this.columnNumber = columnNumber; |
| 81 |
0 |
this.lineNumber = lineNumber; |
| 82 |
0 |
} |
| 83 |
|
|
| 84 |
|
public Throwable getCause() { |
| 85 |
52 |
return cause; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
public int getLineNumber() { |
| 93 |
637 |
return lineNumber; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
public void setLineNumber(int lineNumber) { |
| 100 |
338 |
this.lineNumber = lineNumber; |
| 101 |
338 |
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
public int getColumnNumber() { |
| 107 |
0 |
return columnNumber; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
public void setColumnNumber(int columnNumber) { |
| 114 |
338 |
this.columnNumber = columnNumber; |
| 115 |
338 |
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
public String getFileName() { |
| 121 |
637 |
return fileName; |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
public void setFileName(String fileName) { |
| 128 |
338 |
this.fileName = fileName; |
| 129 |
338 |
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
public String getElementName() { |
| 136 |
637 |
return elementName; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
public void setElementName(String elementName) { |
| 143 |
338 |
this.elementName = elementName; |
| 144 |
338 |
} |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
public String getMessage() { |
| 148 |
78 |
return fileName + ":" + lineNumber + ":" + columnNumber + ": <" + elementName + "> " + getReason(); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
public String getReason() { |
| 152 |
78 |
return super.getMessage(); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
|
| 156 |
|
public void printStackTrace(PrintWriter s) { |
| 157 |
0 |
synchronized (s) { |
| 158 |
0 |
super.printStackTrace(s); |
| 159 |
0 |
if (cause != null) { |
| 160 |
0 |
s.println("Root cause"); |
| 161 |
0 |
cause.printStackTrace(s); |
| 162 |
|
} |
| 163 |
0 |
} |
| 164 |
0 |
} |
| 165 |
|
|
| 166 |
|
public void printStackTrace(PrintStream s) { |
| 167 |
0 |
synchronized (s) { |
| 168 |
0 |
super.printStackTrace(s); |
| 169 |
0 |
if (cause != null) { |
| 170 |
0 |
s.println("Root cause"); |
| 171 |
0 |
cause.printStackTrace(s); |
| 172 |
|
} |
| 173 |
0 |
} |
| 174 |
0 |
} |
| 175 |
|
|
| 176 |
|
public void printStackTrace() { |
| 177 |
0 |
super.printStackTrace(); |
| 178 |
0 |
if (cause != null) { |
| 179 |
0 |
System.out.println("Root cause"); |
| 180 |
0 |
cause.printStackTrace(); |
| 181 |
|
} |
| 182 |
0 |
} |
| 183 |
|
|
| 184 |
|
} |