Class RDPError

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<RDPError>

    public final class RDPError
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<RDPError>

    Represents an Internal Java-Side Failure During WebSocket Communication

    This class is used to represent errors that arise during the execution of internal logic within the Java-based infrastructure responsible for interacting with the Chrome DevTools Protocol (CDP) over WebSockets. It is the conceptual opposite of BrowserError, which represents errors *reported by the browser itself*.

    RDPError instances are thrown or passed downstream whenever an unexpected or invalid condition is detected by the Java-side handlers that process inbound or outbound messages on the WebSocket channel.

    These are *not* errors originating from the browser. Instead, they usually reflect one of the following situations:

    • Failures inside message-processing logic (e.g., malformed or unrecognized JSON)
    • Unchecked runtime exceptions triggered by handler code (e.g., NPE, casting failures)
    • Unexpected conditions raised by the NeoVisionaries WebSocket implementation
    • Structural violations in expected CDP response formats

    RDPError objects can optionally include:

    • A textual message describing the failure
    • The raw JsonObject that caused the error (if applicable)
    • A Throwable that was caught and wrapped


    Causing these Errors:
    All instantiations of this class occur inside one of the four internal infrastructure classes:


    Because these errors reflect misbehavior or malformation in Java-managed logic, they should never be ignored. They often signal bugs in parsing logic, protocol desynchronization, or incorrect assumptions in command/response handling.


    Registering a Handler:
    To receive instances of this error class, a handler must be registered at the time you create your WebSocketSender using one of the createSender(...) methods found in either BrowserConn or PageConn. These methods allow you to provide lambda handlers or consumer functions for error callbacks. Without explicitly setting a handler for this error type, you will never see these errors—they will be silently discarded or ignored by the internal infrastructure.

    Each of the three CDP error/response types — RDPError, BrowserError, and BrowserEvent — has its own dedicated handler. These are supplied as Consumer arguments to createSender(...), and any logic you wish to perform in response to these events must be defined there. The WebSocketSender will invoke these handlers automatically whenever it receives a message of the corresponding kind.
    See Also:
    Serialized Form


    • Method Summary

       
      Methods: class java.lang.Object
      Modifier and Type Method
      boolean equals​(Object o)
      int hashCode()
      String toString()
       
      Methods: interface java.lang.Comparable
      Modifier and Type Method
      int compareTo​(RDPError error)
      • Methods inherited from class java.lang.Object

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

      • serialVersionUID

        🡇     🗕  🗗  🗖
        protected static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         protected static final long serialVersionUID = 1;
        
      • message

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String message
        A descriptive message explaining the nature of the internal error.

        This string is almost always provided by the handler logic itself to contextualize what went wrong — e.g., "Unrecognized ID field", "Unexpected type in CDP response", or "Missing 'method' property in event dispatch."
        Code:
        Exact Field Declaration Expression:
         public final String message;
        
      • cause

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.Throwable cause
        The underlying exception or cause that led to this RDPError.

        This may include NullPointerException, ClassCastException, or any other unchecked exception that occurred during handler execution. It may be null if the error was raised directly without an underlying Throwable.
        Code:
        Exact Field Declaration Expression:
         public final Throwable cause;
        
      • jo

        🡅  🡇     🗕  🗗  🗖
        public final JsonObject jo
        The raw JsonObject that was being processed at the time the error occurred.

        This field is useful for debugging. It often contains the browser's CDP response that the Java code failed to parse or recognize. It may be null if the failure was unrelated to message content (e.g., a runtime exception).
        Code:
        Exact Field Declaration Expression:
         public final JsonObject jo;
        
    • Method Detail

      • toString

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Code:
        Exact Method Body:
         final String jsonStr = (jo == null)
             ? "    JSON: NULL"
             : ("    JSON: \n" + PrintUtil.json2(jo));
        
         final String causeStr = (cause == null)
             ? "    Cause Throwable: NULL"
             : ("    Cause: \n" + EXCC.toString(cause));
        
         return 
             "RDPError Object\n" +
             "{\n" +
                 "    Message: " + message + '\n' +
                 jsonStr + '\n' +
                 causeStr + '\n' +
             '}';
        
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Code:
        Exact Method Body:
         return message.hashCode();
        
      • equals

        🡅  🡇     🗕  🗗  🗖
        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
        Code:
        Exact Method Body:
         if (this == o) return true;
         if (o == null) return false;
        
         if (this.getClass() != o.getClass()) return false;
        
         final RDPError error = (RDPError) o;
        
         return (message.equals(error.message));