1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.message; |
8 | |
|
9 | |
import org.mule.api.MuleException; |
10 | |
import org.mule.api.ExceptionPayload; |
11 | |
import org.mule.config.ExceptionHelper; |
12 | |
|
13 | |
import java.util.Map; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
public class DefaultExceptionPayload implements ExceptionPayload |
20 | |
{ |
21 | |
|
22 | |
|
23 | |
|
24 | |
private static final long serialVersionUID = -7114836033686599024L; |
25 | |
|
26 | 0 | private int code = 0; |
27 | 0 | private String message = null; |
28 | 0 | private Map info = null; |
29 | |
private Throwable exception; |
30 | |
|
31 | |
public DefaultExceptionPayload(Throwable exception) |
32 | 0 | { |
33 | 0 | this.exception = exception; |
34 | 0 | MuleException muleRoot = ExceptionHelper.getRootMuleException(exception); |
35 | 0 | if (muleRoot != null) |
36 | |
{ |
37 | 0 | message = muleRoot.getMessage(); |
38 | 0 | code = muleRoot.getExceptionCode(); |
39 | 0 | info = muleRoot.getInfo(); |
40 | |
} |
41 | |
else |
42 | |
{ |
43 | 0 | message = exception.getMessage(); |
44 | |
} |
45 | 0 | } |
46 | |
|
47 | |
public Throwable getRootException() |
48 | |
{ |
49 | 0 | return ExceptionHelper.getRootException(exception); |
50 | |
} |
51 | |
|
52 | |
public int getCode() |
53 | |
{ |
54 | 0 | return code; |
55 | |
} |
56 | |
|
57 | |
public String getMessage() |
58 | |
{ |
59 | 0 | return message; |
60 | |
} |
61 | |
|
62 | |
public Map getInfo() |
63 | |
{ |
64 | 0 | return info; |
65 | |
} |
66 | |
|
67 | |
public Throwable getException() |
68 | |
{ |
69 | 0 | return exception; |
70 | |
} |
71 | |
|
72 | |
} |