1 package eu
.etaxonomy
.cdm
.io
.jaxb
;
3 import java
.util
.ArrayList
;
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
;
14 import org
.springframework
.core
.annotation
.AnnotationUtils
;
16 @XmlAccessorType(XmlAccessType
.FIELD
)
17 @XmlType(name
= "Error", propOrder
= {
24 @XmlRootElement(name
= "Error")
27 private Integer status
;
29 @XmlElement(name
= "Message")
30 private String message
;
32 @XmlElement(name
= "Resource")
33 private String resource
;
35 @XmlElement(name
= "Cause")
38 @XmlElement(name
= "Code")
41 @XmlElementWrapper(name
= "StackTrace")
42 @XmlElement(name
= "StackTraceElement")
43 private List
<String
> stackTrace
;
49 public Error(Throwable throwable
) {
50 if(throwable
.getCause() != null) {
51 this.cause
= throwable
.getCause().getClass().getName();
53 this.message
= throwable
.getLocalizedMessage();
54 this.stackTrace
= new ArrayList
<String
>();
55 for(StackTraceElement ste
: throwable
.getStackTrace()) {
56 this.stackTrace
.add(ste
.toString());
60 public Integer
getStatus() {
64 public void setStatus(Integer status
) {
68 public String
getMessage() {
72 public void setMessage(String message
) {
73 this.message
= message
;
76 public String
getResource() {
80 public void setResource(String resource
) {
81 this.resource
= resource
;
84 public String
getCause() {
88 public void setCause(String cause
) {
92 public String
getCode() {
96 public void setCode(String code
) {
100 public List
<String
> getStackTrace() {
104 public void setStackTrace(List
<String
> stackTrace
) {
105 this.stackTrace
= stackTrace
;