-
Notifications
You must be signed in to change notification settings - Fork 56
/
errors.go
41 lines (32 loc) · 948 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
package grizzly
import (
"errors"
"fmt"
)
var (
// ErrNotFound is used to signal a missing resource
ErrNotFound = errors.New("not found")
// ErrNotImplemented signals a feature that is not supported by a provider
ErrNotImplemented = errors.New("not implemented")
// ErrHandlerNotFound indicates that no handler was found for a particular resource Kind.
ErrHandlerNotFound = errors.New("handler not found")
)
// APIErr encapsulates an error from the Grafana API
type APIErr struct {
Err error
Body []byte
}
func (e APIErr) Error() string {
return fmt.Sprintf("Failed to parse Grafana response: %s.\n\nResponse:\n%s", e.Err, string(e.Body))
}
type UnrecognisedFormatError struct {
File string
}
func (e UnrecognisedFormatError) Error() string {
return fmt.Sprintf("unrecognized format for %s", e.File)
}
func NewUnrecognisedFormatError(file string) UnrecognisedFormatError {
return UnrecognisedFormatError{
File: file,
}
}