-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforbidden_resource_error.go
More file actions
63 lines (51 loc) · 2.19 KB
/
forbidden_resource_error.go
File metadata and controls
63 lines (51 loc) · 2.19 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"
)
// ForbiddenResourceError is used when the resource cannot be accessed by authenticated user.
type ForbiddenResourceError struct {
*ErrorWithKey
}
// NewForbiddenResourceError is used when the resource cannot be accessed by authenticated user.
func NewForbiddenResourceError(code, key string) error {
return WrapWithForbiddenResourceError(nil, code, key)
}
// NewForbiddenResourceErrorf is used when the resource cannot be accessed by authenticated user.
func NewForbiddenResourceErrorf(code, key string, args ...any) error {
return WrapWithForbiddenResourceErrorf(nil, code, key, args...)
}
// WrapWithForbiddenResourceError is used when the resource cannot be accessed by authenticated user.
func WrapWithForbiddenResourceError(err error, code, key string) error {
return NewError[ForbiddenResourceError](code, key, http.StatusForbidden, err)
}
// WrapWithForbiddenResourceErrorf is used when the resource cannot be accessed by authenticated user.
func WrapWithForbiddenResourceErrorf(err error, code, key string, args ...any) error {
return NewError[ForbiddenResourceError](code, fmt.Sprintf(key, args...), http.StatusForbidden, err)
}
// IsForbiddenResourceError identifies an error as an ForbiddenResourceError.
func IsForbiddenResourceError(err error) bool {
return Is[ForbiddenResourceError](err)
}
// AsForbiddenResourceError tries to cast an error as an ForbiddenResourceError.
func AsForbiddenResourceError(err error) (*ForbiddenResourceError, bool) {
return As[ForbiddenResourceError](err)
}
// Is is used by the standard "errors" package to identify an error as ForbiddenResourceError.
func (e *ForbiddenResourceError) Is(err error) bool {
_, ok := err.(*ForbiddenResourceError)
return ok
}
// As is used by the standard "errors" package to identify an error as ForbiddenResourceError.
func (e *ForbiddenResourceError) As(err interface{}) bool {
err2, ok := err.(*ForbiddenResourceError)
if ok {
*err2 = *e
}
return ok
}
// Unwrap is used by the standard "errors" package to dive into the error chain.
func (e *ForbiddenResourceError) Unwrap() error {
return e.ErrorWithKey
}