/
errors.go
55 lines (44 loc) · 1.34 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
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package provider
import (
"github.com/juju/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
)
var (
errNoNamespace = errors.NotProvisionedf("bootstrap broker or no namespace")
)
// ClusterQueryError represents an issue when querying a cluster.
type ClusterQueryError struct {
Message string
}
func (e ClusterQueryError) Error() string {
return e.Message
}
// IsClusterQueryError returns true if err is a ClusterQueryError.
func IsClusterQueryError(err error) bool {
_, ok := err.(ClusterQueryError)
return ok
}
// NoRecommendedStorageError represents when Juju is unable to determine which storage a cluster uses (or should use)
type NoRecommendedStorageError struct {
Message string
ProviderName string
}
func (e NoRecommendedStorageError) Error() string {
return e.Message
}
func (e NoRecommendedStorageError) StorageProvider() string {
return e.ProviderName
}
// IsNoRecommendedStorageError returns true if err is a NoRecommendedStorageError
func IsNoRecommendedStorageError(err error) bool {
_, ok := err.(NoRecommendedStorageError)
return ok
}
// MaskError is used to signify that an error
// should not be reported back to the caller.
func MaskError(err error) bool {
_, ok := errors.Cause(err).(*k8serrors.StatusError)
return ok
}