-
Notifications
You must be signed in to change notification settings - Fork 298
/
errors.go
66 lines (53 loc) · 1.8 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
package middleware
import (
"encr.dev/pkg/errors"
)
var (
errRange = errors.Range(
"middleware",
"hint: middleware must have the signature:\n\t"+
"func(req middleware.Request, next middleware.Next) middleware.Response\n\n"+
"For more information on how to use middleware, see https://encore.dev/docs/develop/middleware",
errors.WithRangeSize(20),
)
errInvalidSelectorType = errRange.Newf(
"Invalid middleware selector",
"Middleware target only supports tags a selectors (got '%s').",
)
errWrongNumberParams = errRange.Newf(
"Invalid middleware function",
"Middleware functions must have exactly 2 parameters, found %d parameters.",
)
errWrongNumberResults = errRange.Newf(
"Invalid middleware function",
"Middleware functions must have exactly 1 result, found %d results.",
)
errInvalidFirstParam = errRange.New(
"Invalid middleware function",
"The first parameter of a middleware function must be middleware.Request.",
)
errInvalidSecondParam = errRange.New(
"Invalid middleware function",
"The second parameter of a middleware function must be middleware.Next.",
)
errInvalidReturnType = errRange.New(
"Invalid middleware function",
"The return type of a middleware function must be middleware.Response.",
)
ErrInvalidTargetForService = errRange.Newf(
"Invalid middleware target",
"There are not matching targets in service %q.",
)
ErrInvalidTargetForApp = errRange.New(
"Invalid middleware target",
"There are not matching targets in the application.",
)
ErrSvcMiddlewareNotInService = errRange.New(
"Invalid middleware function",
"Middleware must be defined in a service unless it is marked as being global.",
)
ErrGlobalMiddlewareDefinedInService = errRange.New(
"Invalid middleware function",
"Global middleware cannot be defined in a service.",
)
)