-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors.go
More file actions
72 lines (58 loc) · 1.84 KB
/
Copy patherrors.go
File metadata and controls
72 lines (58 loc) · 1.84 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
64
65
66
67
68
69
70
71
72
package overlay
import (
"fmt"
)
// ValidationError represents an error in the overlay document structure.
type ValidationError struct {
// Field is the name of the field with the error.
Field string
// Path is the location in the overlay document (e.g., "actions[0].target").
Path string
// Message describes the validation error.
Message string
}
// Error implements the error interface.
func (e ValidationError) Error() string {
if e.Path != "" {
return fmt.Sprintf("overlay: validation error at %s: %s", e.Path, e.Message)
}
if e.Field != "" {
return fmt.Sprintf("overlay: validation error in field %q: %s", e.Field, e.Message)
}
return fmt.Sprintf("overlay: validation error: %s", e.Message)
}
// ApplyError represents an error during overlay application.
type ApplyError struct {
// ActionIndex is the zero-based index of the action that failed.
ActionIndex int
// Target is the JSONPath expression that was being evaluated.
Target string
// Cause is the underlying error.
Cause error
}
// Error implements the error interface.
func (e *ApplyError) Error() string {
return fmt.Sprintf("overlay: action[%d] target=%q: %v", e.ActionIndex, e.Target, e.Cause)
}
// Unwrap returns the underlying error for errors.Is/As support.
func (e *ApplyError) Unwrap() error {
return e.Cause
}
// ParseError represents an error during overlay document parsing.
type ParseError struct {
// Path is the file path or source identifier.
Path string
// Cause is the underlying error.
Cause error
}
// Error implements the error interface.
func (e *ParseError) Error() string {
if e.Path != "" {
return fmt.Sprintf("overlay: failed to parse %s: %v", e.Path, e.Cause)
}
return fmt.Sprintf("overlay: failed to parse: %v", e.Cause)
}
// Unwrap returns the underlying error for errors.Is/As support.
func (e *ParseError) Unwrap() error {
return e.Cause
}