/
errors.go
44 lines (34 loc) · 868 Bytes
/
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
package objecttemplate
import (
"fmt"
"strings"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type JSONPathFormatError struct {
Path string
}
func (e *JSONPathFormatError) Error() string {
return fmt.Sprintf("path %s must be a JSONPath with a leading dot", e.Path)
}
type SourceError struct {
Source client.Object
Err error
}
func (e *SourceError) Error() string {
return fmt.Sprintf("for source %s %s: %s",
e.Source.GetObjectKind().GroupVersionKind().Kind,
client.ObjectKeyFromObject(e.Source), e.Err)
}
type SourceKeyNotFoundError struct {
Key string
}
func (e *SourceKeyNotFoundError) Error() string {
return fmt.Sprintf("key %s not found", e.Key)
}
type TemplateError struct {
Err error
}
func (e *TemplateError) Error() string {
// sanitize template error output a bit
return strings.Replace(e.Err.Error(), `executing "" `, "", 1)
}