View Javadoc

1   /*
2    * $Id: ExceptionPayload.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.impl.message;
12  
13  import org.mule.config.ExceptionHelper;
14  import org.mule.umo.UMOException;
15  import org.mule.umo.UMOExceptionPayload;
16  
17  import java.util.Map;
18  
19  /**
20   * <code>ExceptionPayload</code> TODO
21   */
22  
23  public class ExceptionPayload implements UMOExceptionPayload
24  {
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = -7114836033686599024L;
29  
30      private int code = 0;
31      private String message = null;
32      private Map info = null;
33      private Throwable exception;
34  
35      public ExceptionPayload(Throwable exception)
36      {
37          this.exception = exception;
38          UMOException muleRoot = ExceptionHelper.getRootMuleException(exception);
39          if (muleRoot != null)
40          {
41              message = muleRoot.getMessage();
42              code = muleRoot.getExceptionCode();
43              info = muleRoot.getInfo();
44          }
45          else
46          {
47              message = exception.getMessage();
48          }
49      }
50  
51      public Throwable getRootException()
52      {
53          return ExceptionHelper.getRootException(exception);
54      }
55  
56      public int getCode()
57      {
58          return code;
59      }
60  
61      public String getMessage()
62      {
63          return message;
64      }
65  
66      public Map getInfo()
67      {
68          return info;
69      }
70  
71      public Throwable getException()
72      {
73          return exception;
74      }
75  
76  }