01: /*
02: * $Id: DefaultExceptionPayload.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.message;
12:
13: import org.mule.api.MuleException;
14: import org.mule.api.ExceptionPayload;
15: import org.mule.config.ExceptionHelper;
16:
17: import java.util.Map;
18:
19: /**
20: * <code>DefaultExceptionPayload</code> TODO
21: */
22:
23: public class DefaultExceptionPayload implements ExceptionPayload {
24: /**
25: * Serial version
26: */
27: private static final long serialVersionUID = -7114836033686599024L;
28:
29: private int code = 0;
30: private String message = null;
31: private Map info = null;
32: private Throwable exception;
33:
34: public DefaultExceptionPayload(Throwable exception) {
35: this .exception = exception;
36: MuleException muleRoot = ExceptionHelper
37: .getRootMuleException(exception);
38: if (muleRoot != null) {
39: message = muleRoot.getMessage();
40: code = muleRoot.getExceptionCode();
41: info = muleRoot.getInfo();
42: } else {
43: message = exception.getMessage();
44: }
45: }
46:
47: public Throwable getRootException() {
48: return ExceptionHelper.getRootException(exception);
49: }
50:
51: public int getCode() {
52: return code;
53: }
54:
55: public String getMessage() {
56: return message;
57: }
58:
59: public Map getInfo() {
60: return info;
61: }
62:
63: public Throwable getException() {
64: return exception;
65: }
66:
67: }
|