-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
112 lines (95 loc) · 2.69 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Package errors contains error types specific to the Surf library.
package errors
import (
"errors"
"fmt"
)
// Error represents any generic error.
type Error struct {
error
}
// New creates and returns an Error type.
func New(msg string, a ...interface{}) Error {
msg = fmt.Sprintf(msg, a...)
return Error{
error: errors.New(msg),
}
}
// PageNotFound represents a failed attempt to visit a page because the page
// does not exist.
type PageNotFound struct {
error
}
// NewPageNotFound creates and returns a NotFound type.
func NewPageNotFound(msg string, a ...interface{}) PageNotFound {
msg = fmt.Sprintf("Not Found: "+msg, a...)
return PageNotFound{
error: errors.New(msg),
}
}
// LinkNotFound represents a failed attempt to follow a link on a page.
type LinkNotFound struct {
error
}
// NewLinkNotFound creates and returns a LinkNotFound type.
func NewLinkNotFound(msg string, a ...interface{}) LinkNotFound {
msg = fmt.Sprintf("Link Not Found: "+msg, a...)
return LinkNotFound{
error: errors.New(msg),
}
}
// AttributeNotFound represents a failed attempt to read an element attribute.
type AttributeNotFound struct {
error
}
// NewAttributeNotFound creates and returns a AttributeNotFound type.
func NewAttributeNotFound(msg string, a ...interface{}) AttributeNotFound {
msg = fmt.Sprintf(msg, a...)
return AttributeNotFound{
error: errors.New(msg),
}
}
// Location represents a failed attempt to follow a Location header.
type Location struct {
error
}
// NewLocation creates and returns a Location type.
func NewLocation(msg string, a ...interface{}) Location {
msg = fmt.Sprintf(msg, a...)
return Location{
error: errors.New(msg),
}
}
// PageNotLoaded represents a failed attempt to operate on a non-loaded page.
type PageNotLoaded struct {
error
}
// NewPageNotLoaded creates and returns a PageNotLoaded type.
func NewPageNotLoaded(msg string, a ...interface{}) PageNotLoaded {
msg = fmt.Sprintf("Page Not Loaded: "+msg, a...)
return PageNotLoaded{
error: errors.New(msg),
}
}
// ElementNotFound represents a failed attempt to operate on a non-existent page element.
type ElementNotFound struct {
error
}
// NewElementNotFound creates and returns a ElementNotFound type.
func NewElementNotFound(msg string, a ...interface{}) ElementNotFound {
msg = fmt.Sprintf(msg, a...)
return ElementNotFound{
error: errors.New(msg),
}
}
// InvalidFormValue represents a failed attempt to set a form value that is not valid.
type InvalidFormValue struct {
error
}
// NewInvalidFormValue creates and returns a InvalidFormValue type.
func NewInvalidFormValue(msg string, a ...interface{}) InvalidFormValue {
msg = fmt.Sprintf(msg, a...)
return InvalidFormValue{
error: errors.New(msg),
}
}