-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
71 lines (59 loc) · 2.45 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2011, 2012, 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package environs
import (
"fmt"
"github.com/juju/errors"
)
const (
// ErrAvailabilityZoneIndependent is an error that represents if the error
// is independent of any particular availability zone. Juju uses this to
// decide whether or not to attempt the failed operation in another
// availability zone. Errors that conform to
// Is(err, ErrAvailabilityZoneIndependent) will not be reattempted.
ErrAvailabilityZoneIndependent = errors.ConstError("availability zone independent")
// ErrNotBootstrapped reports that the given model is not bootstrapped.
ErrNotBootstrapped = errors.ConstError("model is not bootstrapped")
// ErrPartialInstances reports that the only some of the expected instance
// were found.
ErrPartialInstances = errors.ConstError("only some instances were found")
)
var (
// ErrNotInstances represents and error for describing that no instances
// were found.
// NOTE: 2022-04-01 tlm This error carries some technical debt. Ideally it
// would be nice to make this a ConstError but it's very unclear if this
// error needs to also be represented as a NotFound error. In 2.9 we are
// going to leave it as is but break it for 3.0.
ErrNoInstances = fmt.Errorf("instances %w", errors.NotFound)
)
// ZoneIndependentError wraps err so that it satisfy
// Is(err, ErrAvailabilityZoneIndependent) and the errors.Locationer interface.
// If a nil error is provider then a nil error is returned.
func ZoneIndependentError(err error) error {
return errors.SetLocation(
errors.WithType(err, ErrAvailabilityZoneIndependent),
1,
)
}
// PreferredStorageNotFound is an error that indicates to the caller the environ
// was unable to completes it's operation because it could not find the storage
// it prefers for the operation. i.e aws block storage or Kubernetes cluster
// storage.
type PreferredStorageNotFound struct {
Message string
}
// NominatedStorageNotFound is an error that indicates the storage the user
// nominated to use for a specific operation was not found and needs to be
// checked for existence or typo's.
type NominatedStorageNotFound struct {
StorageName string
}
// Error implements the error interface
func (p *PreferredStorageNotFound) Error() string {
return p.Message
}
// Error implements the error interface
func (n *NominatedStorageNotFound) Error() string {
return fmt.Sprintf("nominated storage %q not found", n.StorageName)
}