Class 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 new RemoteExceptionCause 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 new RemoteExceptionCause instance with an initial message.
      RemoteExceptionCause​(java.lang.String msg, RemoteExceptionCause cause, java.lang.String exceptionClassName)
      Constructs a new RemoteExceptionCause 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 new RemoteExceptionCause 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 given Throwable.
      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.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RemoteExceptionCause

        public RemoteExceptionCause​(java.lang.String msg,
                                    java.lang.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​(java.lang.String msg,
                                    RemoteExceptionCause cause,
                                    java.lang.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​(java.lang.String msg,
                                    java.lang.String exceptionClassName,
                                    java.util.Map<java.lang.String,​java.lang.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​(java.lang.String msg,
                                    RemoteExceptionCause cause,
                                    java.lang.String exceptionClassName,
                                    java.util.Map<java.lang.String,​java.lang.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 Detail

      • of

        public static RemoteExceptionCause of​(java.lang.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 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 be null)
        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 class java.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 be null)
        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 class java.lang.Throwable