-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvalid_argument_error.go
More file actions
63 lines (51 loc) · 2.05 KB
/
invalid_argument_error.go
File metadata and controls
63 lines (51 loc) · 2.05 KB
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
// Code generated by http://github.com/genesor/errorz (v1.0.0). DO NOT EDIT.
package errorz
import (
"fmt"
"net/http"
)
// InvalidArgumentError is used when the provided argument is incorrect.
type InvalidArgumentError struct {
*ErrorWithKey
}
// NewInvalidArgumentError is used when the provided argument is incorrect.
func NewInvalidArgumentError(code, key string) error {
return WrapWithInvalidArgumentError(nil, code, key)
}
// NewInvalidArgumentErrorf is used when the provided argument is incorrect.
func NewInvalidArgumentErrorf(code, key string, args ...any) error {
return WrapWithInvalidArgumentErrorf(nil, code, key, args...)
}
// WrapWithInvalidArgumentError is used when the provided argument is incorrect.
func WrapWithInvalidArgumentError(err error, code, key string) error {
return NewError[InvalidArgumentError](code, key, http.StatusUnprocessableEntity, err)
}
// WrapWithInvalidArgumentErrorf is used when the provided argument is incorrect.
func WrapWithInvalidArgumentErrorf(err error, code, key string, args ...any) error {
return NewError[InvalidArgumentError](code, fmt.Sprintf(key, args...), http.StatusUnprocessableEntity, err)
}
// IsInvalidArgumentError identifies an error as an InvalidArgumentError.
func IsInvalidArgumentError(err error) bool {
return Is[InvalidArgumentError](err)
}
// AsInvalidArgumentError tries to cast an error as an InvalidArgumentError.
func AsInvalidArgumentError(err error) (*InvalidArgumentError, bool) {
return As[InvalidArgumentError](err)
}
// Is is used by the standard "errors" package to identify an error as InvalidArgumentError.
func (e *InvalidArgumentError) Is(err error) bool {
_, ok := err.(*InvalidArgumentError)
return ok
}
// As is used by the standard "errors" package to identify an error as InvalidArgumentError.
func (e *InvalidArgumentError) As(err interface{}) bool {
err2, ok := err.(*InvalidArgumentError)
if ok {
*err2 = *e
}
return ok
}
// Unwrap is used by the standard "errors" package to dive into the error chain.
func (e *InvalidArgumentError) Unwrap() error {
return e.ErrorWithKey
}