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:
  • Constructor Details

    • RemoteExceptionCause

      public RemoteExceptionCause(String msg, String exceptionClassName)
      Constructs a new RemoteExceptionCause instance with an initial message. No cause is specified.
      Parameters:
      msg - the message
      exceptionClassName - the name of the exception's class (must not be null)
    • RemoteExceptionCause

      public RemoteExceptionCause(String msg, RemoteExceptionCause cause, String exceptionClassName)
      Constructs a new RemoteExceptionCause instance with an initial message and cause.
      Parameters:
      msg - the message
      cause - the cause
      exceptionClassName - the name of the exception's class (must not be null)
    • RemoteExceptionCause

      public RemoteExceptionCause(String msg, String exceptionClassName, Map<String,String> fields)
      Constructs a new RemoteExceptionCause instance with an initial message. No cause is specified.
      Parameters:
      msg - the message
      exceptionClassName - the name of the exception's class (must not be null)
      fields - the public fields of the remote exception (must not be null)
    • RemoteExceptionCause

      public RemoteExceptionCause(String msg, RemoteExceptionCause cause, String exceptionClassName, Map<String,String> fields)
      Constructs a new RemoteExceptionCause instance with an initial message and cause.
      Parameters:
      msg - the message
      cause - the cause
      exceptionClassName - the name of the exception's class (must not be null)
      fields - the public fields of the remote exception (must not be null)
  • Method Details

    • of

      public static RemoteExceptionCause of(Throwable t)
      Get a remote exception cause for the given Throwable. All of the cause and suppressed exceptions will also be converted.
      Parameters:
      t - the throwable, or null
      Returns:
      the remote exception cause, or null if null was 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 be null)
      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.
      Overrides:
      toString in class Throwable
      Returns:
      the string representation of the exception
    • 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 be null)
      Throws:
      IOException - if an error occurs writing the data
    • readFromStream

      public static RemoteExceptionCause readFromStream(DataInput input) throws IOException
      Throws:
      IOException
    • getCause

      public RemoteExceptionCause getCause()
      Overrides:
      getCause in class Throwable