View Javadoc

1   /*
2    * $Id: ErrorMessage.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.example.errorhandler;
12  
13  import java.util.HashMap;
14  import java.util.Map;
15  
16  /**
17   * The <code>ErrorMessage</code> represents an exception.
18   */
19  public class ErrorMessage
20  {
21      // Bean representing the Exception
22      private ExceptionBean exception;
23      // The exception itself, in its primitive state
24      private Throwable throwable;
25      // Properties for this object
26      private Map properties = new HashMap();
27  
28      /**
29       *
30       */
31      public ErrorMessage()
32      {
33          super();
34      }
35  
36      public ErrorMessage(ExceptionBean exception) throws InstantiationException
37      {
38          setException(exception);
39      }
40  
41      public ErrorMessage(Throwable exception)
42      {
43          setThrowable(exception);
44      }
45  
46      public ErrorMessage(Throwable exception, Map props)
47      {
48          setThrowable(exception);
49          setProperties(props);
50      }
51  
52      /**
53       * @return Returns the exception.
54       */
55      public ExceptionBean getException()
56      {
57          return exception;
58      }
59  
60      /**
61       * @param exception The exception to set.
62       */
63      public void setException(ExceptionBean exception) throws InstantiationException
64      {
65          this.exception = exception;
66          throwable = exception.toException();
67      }
68  
69      /**
70       * @return Returns the properties.
71       */
72      public Map getProperties()
73      {
74          return properties;
75      }
76  
77      /**
78       * @param properties The properties to set.
79       */
80      public void setProperties(Map properties)
81      {
82          this.properties = properties;
83      }
84  
85      /**
86       * @return Returns the throwable.
87       */
88      public Throwable getThrowable()
89      {
90          return throwable;
91      }
92  
93      /**
94       * @param throwable The throwable to set.
95       */
96      public void setThrowable(Throwable throwable)
97      {
98          this.throwable = throwable;
99          exception = new ExceptionBean(throwable);
100     }
101 
102 }