Package org.wildfly.common.rpc
Class RemoteExceptionCause
- java.lang.Object
-
- java.lang.Throwable
-
- org.wildfly.common.rpc.RemoteExceptionCause
-
- All Implemented Interfaces:
java.io.Serializable
public final class RemoteExceptionCause extends java.lang.Throwable
A remote exception cause. Instances of this class are intended to aid with diagnostics and are not intended to be directly thrown. They may be added to other exception types as a cause or suppressed throwable.- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RemoteExceptionCause(java.lang.String msg, java.lang.String exceptionClassName)
Constructs a newRemoteExceptionCause
instance with an initial message.RemoteExceptionCause(java.lang.String msg, java.lang.String exceptionClassName, java.util.Map<java.lang.String,java.lang.String> fields)
Constructs a newRemoteExceptionCause
instance with an initial message.RemoteExceptionCause(java.lang.String msg, RemoteExceptionCause cause, java.lang.String exceptionClassName)
Constructs a newRemoteExceptionCause
instance with an initial message and cause.RemoteExceptionCause(java.lang.String msg, RemoteExceptionCause cause, java.lang.String exceptionClassName, java.util.Map<java.lang.String,java.lang.String> fields)
Constructs a newRemoteExceptionCause
instance with an initial message and cause.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RemoteExceptionCause
getCause()
java.lang.String
getExceptionClassName()
Get the original exception class name.java.util.Set<java.lang.String>
getFieldNames()
Get the field names of the remote exception.java.lang.String
getFieldValue(java.lang.String fieldName)
Get the string value of the given field name.static RemoteExceptionCause
of(java.lang.Throwable t)
Get a remote exception cause for the givenThrowable
.static RemoteExceptionCause
readFromStream(java.io.DataInput input)
java.lang.Throwable
toPlainThrowable()
Convert this remote exception cause to a plain throwable for sending to peers which use serialization and do not have this class present.java.lang.String
toString()
Get a string representation of this exception.void
writeToStream(java.io.DataOutput output)
Write this remote exception cause to the given stream, without using serialization.
-
-
-
Constructor Detail
-
RemoteExceptionCause
public RemoteExceptionCause(java.lang.String msg, java.lang.String exceptionClassName)
Constructs a newRemoteExceptionCause
instance with an initial message. No cause is specified.- Parameters:
msg
- the messageexceptionClassName
- the name of the exception's class (must not benull
)
-
RemoteExceptionCause
public RemoteExceptionCause(java.lang.String msg, RemoteExceptionCause cause, java.lang.String exceptionClassName)
Constructs a newRemoteExceptionCause
instance with an initial message and cause.- Parameters:
msg
- the messagecause
- the causeexceptionClassName
- the name of the exception's class (must not benull
)
-
RemoteExceptionCause
public RemoteExceptionCause(java.lang.String msg, java.lang.String exceptionClassName, java.util.Map<java.lang.String,java.lang.String> fields)
Constructs a newRemoteExceptionCause
instance with an initial message. No cause is specified.- Parameters:
msg
- the messageexceptionClassName
- the name of the exception's class (must not benull
)fields
- the public fields of the remote exception (must not benull
)
-
RemoteExceptionCause
public RemoteExceptionCause(java.lang.String msg, RemoteExceptionCause cause, java.lang.String exceptionClassName, java.util.Map<java.lang.String,java.lang.String> fields)
Constructs a newRemoteExceptionCause
instance with an initial message and cause.- Parameters:
msg
- the messagecause
- the causeexceptionClassName
- the name of the exception's class (must not benull
)fields
- the public fields of the remote exception (must not benull
)
-
-
Method Detail
-
of
public static RemoteExceptionCause of(java.lang.Throwable t)
Get a remote exception cause for the givenThrowable
. All of the cause and suppressed exceptions will also be converted.- Parameters:
t
- the throwable, ornull
- Returns:
- the remote exception cause, or
null
ifnull
was passed in
-
toPlainThrowable
public java.lang.Throwable toPlainThrowable()
Convert this remote exception cause to a plain throwable for sending to peers which use serialization and do not have this class present. Note that this does not recursively apply; normally, a serialization framework will handle the recursive application of this operation through object resolution.- Returns:
- the throwable (not
null
)
-
getExceptionClassName
public java.lang.String getExceptionClassName()
Get the original exception class name.- Returns:
- the original exception class name (not
null
)
-
getFieldNames
public java.util.Set<java.lang.String> getFieldNames()
Get the field names of the remote exception.- Returns:
- the field names of the remote exception
-
getFieldValue
public java.lang.String getFieldValue(java.lang.String fieldName)
Get the string value of the given field name.- Parameters:
fieldName
- the name of the field (must not benull
)- Returns:
- the string value of the given field name
-
toString
public java.lang.String toString()
Get a string representation of this exception. The representation will return an indication of the fact that this was a remote exception, the remote exception type, and optionally details of the exception content, followed by the exception message.- Overrides:
toString
in classjava.lang.Throwable
- Returns:
- the string representation of the exception
-
writeToStream
public void writeToStream(java.io.DataOutput output) throws java.io.IOException
Write this remote exception cause to the given stream, without using serialization.- Parameters:
output
- the output stream (must not benull
)- Throws:
java.io.IOException
- if an error occurs writing the data
-
readFromStream
public static RemoteExceptionCause readFromStream(java.io.DataInput input) throws java.io.IOException
- Throws:
java.io.IOException
-
getCause
public RemoteExceptionCause getCause()
- Overrides:
getCause
in classjava.lang.Throwable
-
-