-
Notifications
You must be signed in to change notification settings - Fork 2
/
errors.go
92 lines (79 loc) · 3.09 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This file is part of marionette-go
//
// marionette-go is distributed in two licenses: The Mozilla Public License,
// v. 2.0 and the GNU Lesser Public License.
//
// marionette-go is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.
//
// See License.txt for further information.
package marionette
import "fmt"
// ErrType denotes type of error returned from marionette server
type ErrType string
const (
ErrElementClickIntercepted = ErrType("element click intercepted")
ErrElementNotInteractable = ErrType("element not interactable")
ErrInsecureCertificate = ErrType("insecure certificate")
ErrInvalidArgument = ErrType("invalid argument")
ErrInvalidCookieDomain = ErrType("invalid cookie domain")
ErrInvalidElementState = ErrType("invalid element state")
ErrInvalidSelector = ErrType("invalid selector")
ErrInvalidSessionId = ErrType("invalid session id")
ErrJavascriptError = ErrType("javascript error")
ErrMoveTargetOutOfBounds = ErrType("move target out of bounds")
ErrNoSuchAlert = ErrType("no such alert")
ErrNoSuchCookie = ErrType("no such cookie")
ErrNoSuchElement = ErrType("no such element")
ErrNoSuchFrame = ErrType("no such frame")
ErrNoSuchWindow = ErrType("no such window")
ErrScriptTimeout = ErrType("script timeout")
ErrSessionNotCreated = ErrType("session not created")
ErrStaleElementReference = ErrType("stale element reference")
ErrTimeout = ErrType("timeout")
ErrUnableToSetCookie = ErrType("unable to set cookie")
ErrUnableToCapturescreen = ErrType("unable to capture screen")
ErrUnexpecteDalertopen = ErrType("unexpected alert open")
ErrUnknownCommand = ErrType("unknown command")
ErrUnknownError = ErrType("unknown error")
ErrUnknownMethod = ErrType("unknown method")
ErrUnsupportedOperation = ErrType("unsupported operation")
)
// ErrDriver is error returned from marionette server
type ErrDriver struct {
Type ErrType `json:"error"`
Message string `json:"message"`
StackTrace string `json:"stacktrace"`
}
func (e *ErrDriver) Error() (ret string) {
return "mario error: " + string(e.Type) + ": " + e.Message
}
func (e *ErrDriver) String() (ret string) {
return fmt.Sprintf("%+v", map[string]interface{}{
"type": e.Type,
"message": e.Message,
"stacktrace": e.StackTrace,
})
}
// ErrResponseDecode denotes we are failed to decode incoming data as Message
type ErrResponseDecode struct {
Err error
}
func (e *ErrResponseDecode) Error() (ret string) {
return e.Err.Error()
}
func (e *ErrResponseDecode) String() (ret string) {
return e.Err.Error()
}
// ErrConnection denotes some network related problem occurred
type ErrConnection struct {
When string
Origin error
}
func (e *ErrConnection) Error() (ret string) {
return e.Origin.Error()
}
func (e *ErrConnection) String() (ret string) {
return "connection error when " + e.When + ": " + e.Origin.Error()
}