-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy patherrors.go
53 lines (43 loc) · 1.09 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
package analysis
import (
"errors"
"fmt"
)
type analysisError string
const (
ErrAnalysis analysisError = "analysis error"
ErrNoSchema analysisError = "no schema to analyze"
)
func (e analysisError) Error() string {
return string(e)
}
func ErrAtKey(key string, err error) error {
return errors.Join(
fmt.Errorf("key %s: %w", key, err),
ErrAnalysis,
)
}
func ErrInvalidRef(key string) error {
return fmt.Errorf("invalid reference: %q: %w", key, ErrAnalysis)
}
func ErrInvalidParameterRef(key string) error {
return fmt.Errorf("resolved reference is not a parameter: %q: %w", key, ErrAnalysis)
}
func ErrResolveSchema(err error) error {
return errors.Join(
fmt.Errorf("could not resolve schema: %w", err),
ErrAnalysis,
)
}
func ErrRewriteRef(key string, target any, err error) error {
return errors.Join(
fmt.Errorf("failed to rewrite ref for key %q at %v: %w", key, target, err),
ErrAnalysis,
)
}
func ErrInlineDefinition(key string, err error) error {
return errors.Join(
fmt.Errorf("error while creating definition %q from inline schema: %w", key, err),
ErrAnalysis,
)
}