Package rx.exceptions

Class OnErrorThrowable

  • All Implemented Interfaces:
    java.io.Serializable

    public final class OnErrorThrowable
    extends java.lang.RuntimeException
    Represents a Throwable that an Observable might notify its subscribers of, but that then can be handled by an operator that is designed to recover from or react appropriately to such an error. You can recover more information from an OnErrorThrowable than is found in a typical Throwable, such as the item the Observable was trying to emit at the time the error was encountered.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  OnErrorThrowable.OnNextValue
      Represents an exception that was encountered while trying to emit an item from an Observable, and tries to preserve that item for future use and/or reporting.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean hasValue  
      private static long serialVersionUID  
      private java.lang.Object value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private OnErrorThrowable​(java.lang.Throwable exception)  
      private OnErrorThrowable​(java.lang.Throwable exception, java.lang.Object value)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Throwable addValueAsLastCause​(java.lang.Throwable e, java.lang.Object value)
      Adds the given item as the final cause of the given Throwable, wrapped in OnNextValue (which extends RuntimeException).
      static OnErrorThrowable from​(java.lang.Throwable t)
      Converts a Throwable into an OnErrorThrowable.
      java.lang.Object getValue()
      Get the value associated with this OnErrorThrowable
      boolean isValueNull()
      Indicates whether or not there is a value associated with this OnErrorThrowable
      • Methods inherited from class java.lang.Throwable

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

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

      • hasValue

        private final boolean hasValue
      • value

        private final java.lang.Object value
    • Constructor Detail

      • OnErrorThrowable

        private OnErrorThrowable​(java.lang.Throwable exception)
      • OnErrorThrowable

        private OnErrorThrowable​(java.lang.Throwable exception,
                                 java.lang.Object value)
    • Method Detail

      • getValue

        public java.lang.Object getValue()
        Get the value associated with this OnErrorThrowable
        Returns:
        the value associated with this OnErrorThrowable (or null if there is none)
      • isValueNull

        public boolean isValueNull()
        Indicates whether or not there is a value associated with this OnErrorThrowable
        Returns:
        true if there is a value associated with this OnErrorThrowable, otherwise false
      • from

        public static OnErrorThrowable from​(java.lang.Throwable t)
        Converts a Throwable into an OnErrorThrowable.
        Parameters:
        t - the Throwable to convert; if null, a NullPointerException is constructed
        Returns:
        an OnErrorThrowable representation of t
      • addValueAsLastCause

        public static java.lang.Throwable addValueAsLastCause​(java.lang.Throwable e,
                                                              java.lang.Object value)
        Adds the given item as the final cause of the given Throwable, wrapped in OnNextValue (which extends RuntimeException).
        Parameters:
        e - the Throwable to which you want to add a cause
        value - the item you want to add to e as the cause of the Throwable
        Returns:
        the same Throwable (e) that was passed in, with value added to it as a cause