org.neo4j.helpers
Class Exceptions

java.lang.Object
  extended by org.neo4j.helpers.Exceptions

public class Exceptions
extends Object


Method Summary
static boolean contains(Throwable cause, Class... anyOfTheseClasses)
           
static Predicate<Throwable> exceptionsOfType(Class<? extends Throwable>... types)
           
static
<T extends Throwable>
T
launderedException(Class<T> type, String messageForUnexpected, Throwable exception)
           
static
<T extends Throwable>
T
launderedException(Class<T> type, Throwable exception)
           
static RuntimeException launderedException(String messageForUnexpected, Throwable exception)
           
static RuntimeException launderedException(Throwable exception)
           
static Throwable peel(Throwable exception, Predicate<Throwable> toPeel)
          Peels off layers of causes.
static Throwable rootCause(Throwable caughtException)
           
static String stringify(Thread thread, StackTraceElement[] elements)
           
static String stringify(Throwable cause)
           
static
<T extends Throwable>
T
withCause(T exception, Throwable cause)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withCause

public static <T extends Throwable> T withCause(T exception,
                                                Throwable cause)

launderedException

public static RuntimeException launderedException(Throwable exception)

launderedException

public static RuntimeException launderedException(String messageForUnexpected,
                                                  Throwable exception)

launderedException

public static <T extends Throwable> T launderedException(Class<T> type,
                                                         Throwable exception)

launderedException

public static <T extends Throwable> T launderedException(Class<T> type,
                                                         String messageForUnexpected,
                                                         Throwable exception)

peel

public static Throwable peel(Throwable exception,
                             Predicate<Throwable> toPeel)
Peels off layers of causes. For example: MyFarOuterException cause: MyOuterException cause: MyInnerException cause: MyException and a toPeel predicate returning true for MyFarOuterException and MyOuterException will return MyInnerException. If the predicate peels all exceptions null is returned.

Parameters:
exception - the outer exception to peel to get to an inner cause.
toPeel - Predicate for deciding what to peel. true means to peel (i.e. remove), whereas the first false means stop and return.
Returns:
the inner cause of an exception, dictated by the predicate.

exceptionsOfType

public static Predicate<Throwable> exceptionsOfType(Class<? extends Throwable>... types)

rootCause

public static Throwable rootCause(Throwable caughtException)

stringify

public static String stringify(Throwable cause)

stringify

public static String stringify(Thread thread,
                               StackTraceElement[] elements)

contains

public static boolean contains(Throwable cause,
                               Class... anyOfTheseClasses)


Copyright © 2002-2014 The Neo4j Graph Database Project. All Rights Reserved.