-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrors.go
56 lines (49 loc) · 1.66 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
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
package http
import (
"fmt"
gdterrors "github.com/gdt-dev/gdt/errors"
)
var (
// ErrAliasOrURL is returned when the test author failed to provide either
// a URL and Method or specify one of the aliases like GET, POST, or DELETE
ErrAliasOrURL = fmt.Errorf(
"%w: either specify a URL and Method or specify one "+
"of GET, POST, PUT, PATCH or DELETE",
gdterrors.ErrParse,
)
// ErrExpectedLocationHeader indicates that the user specified the special
// `$LOCATION` string in the `url` or `GET` fields of the HTTP test spec
// but there have been no previous HTTP responses to find a Location HTTP
// Header within.
ErrExpectedLocationHeader = fmt.Errorf(
"%w: expected Location HTTP Header in previous response",
gdterrors.RuntimeError,
)
)
// HTTPStatusNotEqual returns an ErrNotEqual when an expected thing doesn't equal an
// observed thing.
func HTTPStatusNotEqual(exp, got interface{}) error {
return fmt.Errorf(
"%w: expected HTTP status %v but got %v",
gdterrors.ErrNotEqual, exp, got,
)
}
// HTTPHeaderNotIn returns an ErrNotIn when an expected header doesn't appear
// in a response's headers.
func HTTPHeaderNotIn(element, container interface{}) error {
return fmt.Errorf(
"%w: expected HTTP headers %v to contain %v",
gdterrors.ErrNotIn, container, element,
)
}
// HTTPNotInBody returns an ErrNotIn when an expected thing doesn't appear in a
// a response's Body.
func HTTPNotInBody(element string) error {
return fmt.Errorf(
"%w: expected HTTP body to contain %v",
gdterrors.ErrNotIn, element,
)
}