FileDocCategorySizeDatePackage
ExceptionUtils.javaAPI DocAndroid 1.5 API3175Wed May 06 22:41:10 BST 2009org.apache.http.util

ExceptionUtils

public final class ExceptionUtils extends Object
The home for utility methods that handle various exception-related tasks.
author
Oleg Kalnichevski
author
Laura Werner
since
4.0

Fields Summary
private static final Method
INIT_CAUSE_METHOD
A reference to Throwable's initCause method, or null if it's not there in this JVM
Constructors Summary
private ExceptionUtils()

    
Methods Summary
private static java.lang.reflect.MethodgetInitCauseMethod()
Returns a Method allowing access to {@link Throwable#initCause(Throwable) initCause} method of {@link Throwable}, or null if the method does not exist.

return
A Method for Throwable.initCause, or null if unavailable.


                                         
        
        try {
            Class[] paramsClasses = new Class[] { Throwable.class };
            return Throwable.class.getMethod("initCause", paramsClasses);
        } catch (NoSuchMethodException e) {
            return null;
        }
    
public static voidinitCause(java.lang.Throwable throwable, java.lang.Throwable cause)
If we're running on JDK 1.4 or later, initialize the cause for the given throwable.

param
throwable The throwable.
param
cause The cause of the throwable.

        if (INIT_CAUSE_METHOD != null) {
            try {
                INIT_CAUSE_METHOD.invoke(throwable, new Object[] { cause });
            } catch (Exception e) {
                // Well, with no logging, the only option is to munch the exception
            }
        }