Class ThrowableProxy
- java.lang.Object
-
- org.apache.logging.log4j.core.impl.ThrowableProxy
-
- All Implemented Interfaces:
java.io.Serializable
public class ThrowableProxy extends java.lang.Object implements java.io.SerializableWraps a Throwable to add packaging information about each stack trace element.A proxy is used to represent a throwable that may not exist in a different class loader or JVM. When an application deserializes a ThrowableProxy, the throwable may not be set, but the throwable's information is preserved in other fields of the proxy like the message and stack trace.
TODO: Move this class to org.apache.logging.log4j.core because it is used from LogEvent.
TODO: Deserialize: Try to rebuild Throwable if the target exception is in this class loader?
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ThrowableProxy(java.lang.Throwable throwable)Constructs the wrapper for the Throwable that includes packaging data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)voidformatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.lang.String suffix)Formats the specified Throwable.voidformatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)Formats the specified Throwable.voidformatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Formats the specified Throwable.ThrowableProxygetCauseProxy()java.lang.StringgetCauseStackTraceAsString(java.lang.String suffix)Formats the Throwable that is the cause of this Throwable.java.lang.StringgetCauseStackTraceAsString(java.util.List<java.lang.String> packages, java.lang.String suffix)Formats the Throwable that is the cause of this Throwable.java.lang.StringgetCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Formats the Throwable that is the cause of this Throwable.intgetCommonElementCount()Returns the number of elements that are being omitted because they are common with the parent Throwable's stack trace.ExtendedStackTraceElement[]getExtendedStackTrace()Gets the stack trace including packaging information.java.lang.StringgetExtendedStackTraceAsString()Format the stack trace including packaging information.java.lang.StringgetExtendedStackTraceAsString(java.lang.String suffix)Format the stack trace including packaging information.java.lang.StringgetExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)Format the stack trace including packaging information.java.lang.StringgetExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Format the stack trace including packaging information.java.lang.StringgetLocalizedMessage()java.lang.StringgetMessage()java.lang.StringgetName()Return the FQCN of the Throwable.java.lang.StackTraceElement[]getStackTrace()ThrowableProxy[]getSuppressedProxies()Gets proxies for suppressed exceptions.java.lang.StringgetSuppressedStackTrace(java.lang.String suffix)Format the suppressed Throwables.java.lang.ThrowablegetThrowable()The throwable or null if this object is deserialized from XML or JSON.inthashCode()java.lang.StringtoString()
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
formatWrapper
public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.lang.String suffix)Formats the specified Throwable.- Parameters:
sb- StringBuilder to contain the formatted Throwable.cause- The Throwable to format.suffix-
-
formatWrapper
public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)Formats the specified Throwable.- Parameters:
sb- StringBuilder to contain the formatted Throwable.cause- The Throwable to format.ignorePackages- The List of packages to be suppressed from the trace.suffix-
-
formatWrapper
public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Formats the specified Throwable.- Parameters:
sb- StringBuilder to contain the formatted Throwable.cause- The Throwable to format.ignorePackages- The List of packages to be suppressed from the trace.textRenderer- The text rendersuffix-
-
getCauseProxy
public ThrowableProxy getCauseProxy()
-
getCauseStackTraceAsString
public java.lang.String getCauseStackTraceAsString(java.lang.String suffix)
Formats the Throwable that is the cause of this Throwable.- Parameters:
suffix-- Returns:
- The formatted Throwable that caused this Throwable.
-
getCauseStackTraceAsString
public java.lang.String getCauseStackTraceAsString(java.util.List<java.lang.String> packages, java.lang.String suffix)Formats the Throwable that is the cause of this Throwable.- Parameters:
packages- The List of packages to be suppressed from the trace.suffix-- Returns:
- The formatted Throwable that caused this Throwable.
-
getCauseStackTraceAsString
public java.lang.String getCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Formats the Throwable that is the cause of this Throwable.- Parameters:
ignorePackages- The List of packages to be suppressed from the trace.textRenderer- the text renderersuffix-- Returns:
- The formatted Throwable that caused this Throwable.
-
getCommonElementCount
public int getCommonElementCount()
Returns the number of elements that are being omitted because they are common with the parent Throwable's stack trace.- Returns:
- The number of elements omitted from the stack trace.
-
getExtendedStackTrace
public ExtendedStackTraceElement[] getExtendedStackTrace()
Gets the stack trace including packaging information.- Returns:
- The stack trace including packaging information.
-
getExtendedStackTraceAsString
public java.lang.String getExtendedStackTraceAsString()
Format the stack trace including packaging information.- Parameters:
suffix-- Returns:
- The formatted stack trace including packaging information.
-
getExtendedStackTraceAsString
public java.lang.String getExtendedStackTraceAsString(java.lang.String suffix)
Format the stack trace including packaging information.- Parameters:
suffix-- Returns:
- The formatted stack trace including packaging information.
-
getExtendedStackTraceAsString
public java.lang.String getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)Format the stack trace including packaging information.- Parameters:
ignorePackages- List of packages to be ignored in the trace.suffix-- Returns:
- The formatted stack trace including packaging information.
-
getExtendedStackTraceAsString
public java.lang.String getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)Format the stack trace including packaging information.- Parameters:
ignorePackages- List of packages to be ignored in the trace.textRenderer- The message renderersuffix-- Returns:
- The formatted stack trace including packaging information.
-
getLocalizedMessage
public java.lang.String getLocalizedMessage()
-
getMessage
public java.lang.String getMessage()
-
getName
public java.lang.String getName()
Return the FQCN of the Throwable.- Returns:
- The FQCN of the Throwable.
-
getStackTrace
public java.lang.StackTraceElement[] getStackTrace()
-
getSuppressedProxies
public ThrowableProxy[] getSuppressedProxies()
Gets proxies for suppressed exceptions.- Returns:
- proxies for suppressed exceptions.
-
getSuppressedStackTrace
public java.lang.String getSuppressedStackTrace(java.lang.String suffix)
Format the suppressed Throwables.- Parameters:
suffix-- Returns:
- The formatted suppressed Throwables.
-
getThrowable
public java.lang.Throwable getThrowable()
The throwable or null if this object is deserialized from XML or JSON.- Returns:
- The throwable or null if this object is deserialized from XML or JSON.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-