Package Torello.Browser
Class BrowserError
- java.lang.Object
-
- Torello.Browser.BrowserError
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<BrowserError>
public class BrowserError extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<BrowserError>
Represents an Error Sent by the Chrome Browser over WebSocket
This class encapsulates error messages originating from the browser itself — not from the Java side, and not from transport-layer failures (like network disconnects or malformed JSON). These errors are generated by the browser's internal logic during its processing of a CDP (Chrome DevTools Protocol) command.
When the browser receives a CDP command that it cannot process correctly — due to invalid parameters, internal issues, or unrecognized method calls — it responds over the WebSocket channel with a structured error message. This message includes both an error code and a textual message describing the problem. This class captures and stores that information in a structured way, so it can be logged, analyzed, or acted upon.
Importantly, this error is not thrown as a Java exception, nor does it represent a problem in the Java-side tooling (e.g., parsing, socket I/O, etc.). It is an intentional error response issued by the browser itself, indicating that a CDP command could not be fulfilled.
Registering a Handler:
To receive instances of this error class, a handler must be registered at the time you create yourWebSocketSenderusing one of thecreateSender(...)methods found in eitherBrowserConnorPageConn. 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, andBrowserEvent— has its own dedicated handler. These are supplied asConsumerarguments tocreateSender(...), and any logic you wish to perform in response to these events must be defined there. TheWebSocketSenderwill invoke these handlers automatically whenever it receives a message of the corresponding kind.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Browser/BrowserError.java
- Open New Browser-Tab: Torello/Browser/BrowserError.java
File Size: 7,365 Bytes Line Count: 171 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field Description protected static longserialVersionUIDInstance Fields Modifier and Type Field Description intcodeThe numeric error code assigned by the browser for this error.StringcommandNameIf this error was generated by a known Command, then the name of that command is saved into this field.DomainsdomainIf this error was generated by a known Domain, then it will be savied into this field.StringmessageThe textual description of the error as provided by Chrome.StringrequestJSONStringThe Json used to build the command.
-
Constructor Summary
Constructors Constructor Description BrowserError(int code, String message)
-
Method Summary
Methods: class java.lang.Object Modifier and Type Method Description booleanequals(Object other)inthashCode()StringtoString()Methods: interface java.lang.Comparable Modifier and Type Method Description intcompareTo(BrowserError error)
-
-
-
Field Detail
-
serialVersionUID
protected static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation 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;
-
code
public final int code
The numeric error code assigned by the browser for this error.
This code is defined internally by the Browser and often (but not always) maps to specific protocol-related error conditions such as "Invalid Parameters", "Target Not Found", or "Method Not Implemented." While not formally documented in all cases, the code can be used to categorize and respond to common failure cases.- Code:
- Exact Field Declaration Expression:
public final int code;
-
message
public final java.lang.String message
The textual description of the error as provided by Chrome.
This message is intended for human readability and often contains hints or clues about why the CDP command failed. It may mention an unsupported method name, a missing argument, or some kind of runtime condition that prevented the browser from fulfilling the request.
While the message is not guaranteed to follow a fixed schema, it is often specific enough to help diagnose problems—especially when debugging command payloads or execution timing.- Code:
- Exact Field Declaration Expression:
public final String message;
-
domain
-
commandName
public final java.lang.String commandName
If this error was generated by a known Command, then the name of that command is saved into this field. If the name is not known, this field will be null.- Code:
- Exact Field Declaration Expression:
public final String commandName;
-
requestJSONString
public final java.lang.String requestJSONString
The Json used to build the command.- Code:
- Exact Field Declaration Expression:
public final String requestJSONString;
-
-
Constructor Detail
-
BrowserError
public BrowserError(int code, java.lang.String message)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Code:
- Exact Method Body:
final String ret = "BrowserError Received:\n" + "{\n" + " Code: " + this.code + '\n' + " Message: " + this.message + '\n'; if (this.domain == null) return ret + '}'; return ret + " Domain: " + this.domain.getPackageName() + '\n' + " Command: " + this.commandName + '}';
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Code:
- Exact Method Body:
return this.code + this.message.hashCode();
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object- Code:
- Exact Method Body:
if (this == other) return true; if (other == null) return false; if (this.getClass() != other.getClass()) return false; final BrowserError o = (BrowserError) other; return (this.code == o.code) && Objects.equals(this.message, o.message) && Objects.equals(this.domain, o.domain) && Objects.equals(this.commandName, o.commandName);
-
compareTo
public int compareTo(BrowserError error)
- Specified by:
compareToin interfacejava.lang.Comparable<BrowserError>- Code:
- Exact Method Body:
if (this.code != error.code) return this.code - error.code; return this.message.compareTo(error.message);
-
-