1
|
package eu.etaxonomy.cdm.io.jaxb;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
|
6
|
import javax.xml.bind.annotation.XmlAccessType;
|
7
|
import javax.xml.bind.annotation.XmlAccessorType;
|
8
|
import javax.xml.bind.annotation.XmlAttribute;
|
9
|
import javax.xml.bind.annotation.XmlElement;
|
10
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
11
|
import javax.xml.bind.annotation.XmlRootElement;
|
12
|
import javax.xml.bind.annotation.XmlType;
|
13
|
|
14
|
import org.springframework.core.annotation.AnnotationUtils;
|
15
|
|
16
|
@XmlAccessorType(XmlAccessType.FIELD)
|
17
|
@XmlType(name = "Error", propOrder = {
|
18
|
"code",
|
19
|
"message",
|
20
|
"resource",
|
21
|
"cause",
|
22
|
"stackTrace"
|
23
|
})
|
24
|
@XmlRootElement(name = "Error")
|
25
|
public class Error {
|
26
|
@XmlAttribute
|
27
|
private Integer status;
|
28
|
|
29
|
@XmlElement(name = "Message")
|
30
|
private String message;
|
31
|
|
32
|
@XmlElement(name = "Resource")
|
33
|
private String resource;
|
34
|
|
35
|
@XmlElement(name = "Cause")
|
36
|
private String cause;
|
37
|
|
38
|
@XmlElement(name = "Code")
|
39
|
private String code;
|
40
|
|
41
|
@XmlElementWrapper(name = "StackTrace")
|
42
|
@XmlElement(name = "StackTraceElement")
|
43
|
private List<String> stackTrace;
|
44
|
|
45
|
public Error() {
|
46
|
|
47
|
}
|
48
|
|
49
|
public Error(Throwable throwable) {
|
50
|
if(throwable.getCause() != null) {
|
51
|
this.cause = throwable.getCause().getClass().getName();
|
52
|
}
|
53
|
this.message = throwable.getLocalizedMessage();
|
54
|
this.stackTrace = new ArrayList<String>();
|
55
|
for(StackTraceElement ste : throwable.getStackTrace()) {
|
56
|
this.stackTrace.add(ste.toString());
|
57
|
}
|
58
|
}
|
59
|
|
60
|
public Integer getStatus() {
|
61
|
return status;
|
62
|
}
|
63
|
|
64
|
public void setStatus(Integer status) {
|
65
|
this.status = status;
|
66
|
}
|
67
|
|
68
|
public String getMessage() {
|
69
|
return message;
|
70
|
}
|
71
|
|
72
|
public void setMessage(String message) {
|
73
|
this.message = message;
|
74
|
}
|
75
|
|
76
|
public String getResource() {
|
77
|
return resource;
|
78
|
}
|
79
|
|
80
|
public void setResource(String resource) {
|
81
|
this.resource = resource;
|
82
|
}
|
83
|
|
84
|
public String getCause() {
|
85
|
return cause;
|
86
|
}
|
87
|
|
88
|
public void setCause(String cause) {
|
89
|
this.cause = cause;
|
90
|
}
|
91
|
|
92
|
public String getCode() {
|
93
|
return code;
|
94
|
}
|
95
|
|
96
|
public void setCode(String code) {
|
97
|
this.code = code;
|
98
|
}
|
99
|
|
100
|
public List<String> getStackTrace() {
|
101
|
return stackTrace;
|
102
|
}
|
103
|
|
104
|
public void setStackTrace(List<String> stackTrace) {
|
105
|
this.stackTrace = stackTrace;
|
106
|
}
|
107
|
}
|