View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.example.errorhandler;
8   
9   import java.util.HashMap;
10  import java.util.Map;
11  
12  /**
13   * The <code>ErrorMessage</code> represents an exception.
14   */
15  public class ErrorMessage
16  {
17      // Bean representing the Exception
18      private ExceptionBean exception;
19      // The exception itself, in its primitive state
20      private Throwable throwable;
21      // Properties for this object
22      private Map properties = new HashMap();
23  
24      /**
25       *
26       */
27      public ErrorMessage()
28      {
29          super();
30      }
31  
32      public ErrorMessage(ExceptionBean exception) throws InstantiationException
33      {
34          setException(exception);
35      }
36  
37      public ErrorMessage(Throwable exception)
38      {
39          setThrowable(exception);
40      }
41  
42      public ErrorMessage(Throwable exception, Map props)
43      {
44          setThrowable(exception);
45          setProperties(props);
46      }
47  
48      /**
49       * @return Returns the exception.
50       */
51      public ExceptionBean getException()
52      {
53          return exception;
54      }
55  
56      /**
57       * @param exception The exception to set.
58       */
59      public void setException(ExceptionBean exception) throws InstantiationException
60      {
61          this.exception = exception;
62          throwable = exception.toException();
63      }
64  
65      /**
66       * @return Returns the properties.
67       */
68      public Map getProperties()
69      {
70          return properties;
71      }
72  
73      /**
74       * @param properties The properties to set.
75       */
76      public void setProperties(Map properties)
77      {
78          this.properties = properties;
79      }
80  
81      /**
82       * @return Returns the throwable.
83       */
84      public Throwable getThrowable()
85      {
86          return throwable;
87      }
88  
89      /**
90       * @param throwable The throwable to set.
91       */
92      public void setThrowable(Throwable throwable)
93      {
94          this.throwable = throwable;
95          exception = new ExceptionBean(throwable);
96      }
97  
98  }