org.mule.config
Class ExceptionHelper

java.lang.Object
  extended by org.mule.config.ExceptionHelper

public final class ExceptionHelper
extends Object

ExceptionHelper provides a number of helper functions that can be useful for dealing with Mule exceptions. This class has 3 core functions -

1. ErrorCode lookup. A corresponding Mule error code can be found using for a given Mule exception 2. Additional Error information such as Java doc url for a given exception can be resolved using this class 3. Error code mappings can be looked up by providing the the protocol to map to and the Mule exception.


Nested Class Summary
static interface ExceptionHelper.ExceptionEvaluator<T>
           
 
Field Summary
static String ERROR_CODE_PROPERTY
          This is the property to set the error code to no the message it is the property name the Transport provider uses set the set the error code on the underlying message
protected static Log logger
          logger used by this class
 
Method Summary
static String getDocUrl(Class<?> exception)
           
static Class getErrorClass(int code)
           
static int getErrorCode(Class exception)
           
static String getErrorCodePropertyName(String protocol)
           
static String getErrorMapping(String protocol, Class exception)
           
static Map getExceptionInfo(Throwable t)
           
static ExceptionReader getExceptionReader(Throwable t)
          Gets an exception reader for the exception
static List getExceptionsAsList(Throwable t)
           
static String getExceptionStack(Throwable t)
           
static String getJavaDocUrl(Class<?> exception)
           
static Throwable getNonMuleException(Throwable t)
           
static Throwable getRootException(Throwable t)
           
static MuleException getRootMuleException(Throwable t)
           
static Throwable getRootParentException(Throwable t)
           
static void registerExceptionReader(ExceptionReader reader)
          Registers an exception reader with Mule
static Throwable sanitize(Throwable t)
          Removes some internal Mule entries from the stacktrace.
static Throwable sanitizeIfNeeded(Throwable t)
           
static Throwable summarise(Throwable t, int depth)
          Removes some internal Mule entries from the stacktrace.
static
<T> T
traverseCauseHierarchy(Throwable e, ExceptionHelper.ExceptionEvaluator<T> evaluator)
           
static
<T extends Throwable>
T
unwrap(T t)
           
static String writeException(Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_CODE_PROPERTY

public static final String ERROR_CODE_PROPERTY
This is the property to set the error code to no the message it is the property name the Transport provider uses set the set the error code on the underlying message

See Also:
Constant Field Values

logger

protected static final Log logger
logger used by this class

Method Detail

getErrorCode

public static int getErrorCode(Class exception)

getErrorClass

public static Class getErrorClass(int code)

getErrorCodePropertyName

public static String getErrorCodePropertyName(String protocol)

getErrorMapping

public static String getErrorMapping(String protocol,
                                     Class exception)

getJavaDocUrl

public static String getJavaDocUrl(Class<?> exception)

getDocUrl

public static String getDocUrl(Class<?> exception)

getRootException

public static Throwable getRootException(Throwable t)

getNonMuleException

public static Throwable getNonMuleException(Throwable t)

sanitizeIfNeeded

public static Throwable sanitizeIfNeeded(Throwable t)

sanitize

public static Throwable sanitize(Throwable t)
Removes some internal Mule entries from the stacktrace. Modifies the passed-in throwable stacktrace.


summarise

public static Throwable summarise(Throwable t,
                                  int depth)
Removes some internal Mule entries from the stacktrace. Modifies the passed-in throwable stacktrace.


getRootParentException

public static Throwable getRootParentException(Throwable t)

getRootMuleException

public static MuleException getRootMuleException(Throwable t)

getExceptionsAsList

public static List getExceptionsAsList(Throwable t)

getExceptionInfo

public static Map getExceptionInfo(Throwable t)

getExceptionStack

public static String getExceptionStack(Throwable t)

registerExceptionReader

public static void registerExceptionReader(ExceptionReader reader)
Registers an exception reader with Mule

Parameters:
reader - the reader to register.

traverseCauseHierarchy

public static <T> T traverseCauseHierarchy(Throwable e,
                                           ExceptionHelper.ExceptionEvaluator<T> evaluator)

getExceptionReader

public static ExceptionReader getExceptionReader(Throwable t)
Gets an exception reader for the exception

Parameters:
t - the exception to get a reader for
Returns:
either a specific reader or an instance of DefaultExceptionReader. This method never returns null;

writeException

public static String writeException(Throwable t)

unwrap

public static <T extends Throwable> T unwrap(T t)


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.