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.config;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.config.ExceptionReader;
11  
12  import java.util.Collections;
13  import java.util.Map;
14  
15  /**
16   * Grabs all information from the MuleException type
17   */
18  public final class MuleExceptionReader implements ExceptionReader
19  {
20  
21      public String getMessage(Throwable t)
22      {
23          return t.getMessage();
24      }
25  
26      public Throwable getCause(Throwable t)
27      {
28          return t.getCause();
29      }
30  
31      public Class<?> getExceptionType()
32      {
33          return MuleException.class;
34      }
35  
36      /**
37       * Returns a map of the non-stanard information stored on the exception
38       * 
39       * @return a map of the non-stanard information stored on the exception
40       */
41      public Map<?, ?> getInfo(Throwable t)
42      {
43          return (t instanceof MuleException ? ((MuleException) t).getInfo() : Collections.EMPTY_MAP);
44      }
45  
46  }