Package org.wildfly.common.rpc
Class RemoteExceptionCause
- java.lang.Object
-
- java.lang.Throwable
-
- org.wildfly.common.rpc.RemoteExceptionCause
-
- All Implemented Interfaces:
Serializable
public final class RemoteExceptionCause extends 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(String msg, String exceptionClassName)Constructs a newRemoteExceptionCauseinstance with an initial message.RemoteExceptionCause(String msg, String exceptionClassName, Map<String,String> fields)Constructs a newRemoteExceptionCauseinstance with an initial message.RemoteExceptionCause(String msg, RemoteExceptionCause cause, String exceptionClassName)Constructs a newRemoteExceptionCauseinstance with an initial message and cause.RemoteExceptionCause(String msg, RemoteExceptionCause cause, String exceptionClassName, Map<String,String> fields)Constructs a newRemoteExceptionCauseinstance with an initial message and cause.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RemoteExceptionCausegetCause()StringgetExceptionClassName()Get the original exception class name.Set<String>getFieldNames()Get the field names of the remote exception.StringgetFieldValue(String fieldName)Get the string value of the given field name.static RemoteExceptionCauseof(Throwable t)Get a remote exception cause for the givenThrowable.static RemoteExceptionCausereadFromStream(DataInput input)ThrowabletoPlainThrowable()Convert this remote exception cause to a plain throwable for sending to peers which use serialization and do not have this class present.StringtoString()Get a string representation of this exception.voidwriteToStream(DataOutput output)Write this remote exception cause to the given stream, without using serialization.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
RemoteExceptionCause
public RemoteExceptionCause(String msg, String exceptionClassName)
Constructs a newRemoteExceptionCauseinstance 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(String msg, RemoteExceptionCause cause, String exceptionClassName)
Constructs a newRemoteExceptionCauseinstance 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(String msg, String exceptionClassName, Map<String,String> fields)
Constructs a newRemoteExceptionCauseinstance 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(String msg, RemoteExceptionCause cause, String exceptionClassName, Map<String,String> fields)
Constructs a newRemoteExceptionCauseinstance 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(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
nullifnullwas passed in
-
toPlainThrowable
public 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 String getExceptionClassName()
Get the original exception class name.- Returns:
- the original exception class name (not
null)
-
getFieldNames
public Set<String> getFieldNames()
Get the field names of the remote exception.- Returns:
- the field names of the remote exception
-
getFieldValue
public String getFieldValue(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 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.
-
writeToStream
public void writeToStream(DataOutput output) throws IOException
Write this remote exception cause to the given stream, without using serialization.- Parameters:
output- the output stream (must not benull)- Throws:
IOException- if an error occurs writing the data
-
readFromStream
public static RemoteExceptionCause readFromStream(DataInput input) throws IOException
- Throws:
IOException
-
getCause
public RemoteExceptionCause getCause()
-
-