Package ghidra.util.exception
Class MultipleCauses
java.lang.Object
java.lang.Throwable
ghidra.util.exception.MultipleCauses
- All Implemented Interfaces:
Serializable
Use an instance of this class as the cause when you need to record several causes of an
exception.
This paradigm would be necessary when multiple attempts can be made to complete a task, e.g.,
traversing a list of plugins until one can handle a given condition. If all attempts fail, it is
desirable to report on each attempt.
This class acts as a wrapper allowing multiple causes to be recorded in place of one. The causes
recorded in this wrapper actually apply to the throwable ("parent") which has this
MultipleCauses exception as its cause.
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new MultipleCauses wrapper with no causes NOTE: it is rude to leave this emptyMultipleCauses
(Collection<Throwable> causes) Constructs a new MultipleCauses wrapper with the given causes -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllCauses
(MultipleCauses that) Add the causes from another MultipleCauses into this onevoid
Assuming a throwable has multiple causes, add them all to this MultipleCausesvoid
Add the cause to the collection of causes (for the "parent" throwable)void
If the throwable has multiple causes, collect its causes into this MultipleCauses.getCause()
Use getCauses insteadReturns the causes of the parent throwable (possibly an empty collection)static boolean
Use addCause insteadboolean
isEmpty()
static void
printTree
(PrintStream out, String prefix, Throwable e) static void
printTree
(PrintStream out, Throwable e) Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MultipleCauses
public MultipleCauses()Constructs a new MultipleCauses wrapper with no causes NOTE: it is rude to leave this empty -
MultipleCauses
Constructs a new MultipleCauses wrapper with the given causes- Parameters:
causes
-
-
-
Method Details
-
getCause
Use getCauses instead -
getCauses
Returns the causes of the parent throwable (possibly an empty collection)- Returns:
- the collection of causes of the parent throwable NOTE: it is rude to leave this empty. If the parent throwable has no cause, or the cause is unknown, leave its cause null.
-
addCause
Add the cause to the collection of causes (for the "parent" throwable)- Parameters:
cause
- the throwable to add as a cause
-
addFlattenedIfMultiple
If the throwable has multiple causes, collect its causes into this MultipleCauses. Otherwise, just add it as a cause.- Parameters:
e
-
-
addAllCauses
Assuming a throwable has multiple causes, add them all to this MultipleCauses- Parameters:
e
- the throwable having multiple causes This is useful for flattening causes into a common exception. For instance, if a method is collecting multiple causes for a potential WidgetException, and it catches a WidgetException, instead of collecting the caught WidgetException, it might instead copy its causes into its own collection.
-
addAllCauses
Add the causes from another MultipleCauses into this one- Parameters:
that
- the source to copy from
-
initCause
Use addCause instead -
isEmpty
public boolean isEmpty() -
hasMultiple
-
printTree
-
printTree
-