vendor/github.com/go-rod/rod/lib/cdp/error.go
65 lines · 1300 bytes
1package cdp
2
3import (
4 "fmt"
5)
6
7// Error of the Response.
8type Error struct {
9 Code int `json:"code"`
10 Message string `json:"message"`
11 Data string `json:"data"`
12}
13
14// Error stdlib interface.
15func (e *Error) Error() string {
16 return fmt.Sprintf("%v", *e)
17}
18
19// Is stdlib interface.
20func (e Error) Is(target error) bool {
21 err, ok := target.(*Error)
22 return ok && e == *err
23}
24
25// ErrCtxNotFound type.
26var ErrCtxNotFound = &Error{
27 Code: -32000,
28 Message: "Cannot find context with specified id",
29}
30
31// ErrSessionNotFound type.
32var ErrSessionNotFound = &Error{
33 Code: -32001,
34 Message: "Session with given id not found.",
35}
36
37// ErrSearchSessionNotFound type.
38var ErrSearchSessionNotFound = &Error{
39 Code: -32000,
40 Message: "No search session with given id found",
41}
42
43// ErrCtxDestroyed type.
44var ErrCtxDestroyed = &Error{
45 Code: -32000,
46 Message: "Execution context was destroyed.",
47}
48
49// ErrObjNotFound type.
50var ErrObjNotFound = &Error{
51 Code: -32000,
52 Message: "Could not find object with given id",
53}
54
55// ErrNodeNotFoundAtPos type.
56var ErrNodeNotFoundAtPos = &Error{
57 Code: -32000,
58 Message: "No node found at given location",
59}
60
61// ErrNotAttachedToActivePage type.
62var ErrNotAttachedToActivePage = &Error{
63 Code: -32000,
64 Message: "Not attached to an active page",
65}