/
errors.go
61 lines (50 loc) · 1.36 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
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package testing
import (
"fmt"
"github.com/juju/juju/rpc/params"
)
var ErrUnauthorized = ¶ms.Error{
Message: "permission denied",
Code: params.CodeUnauthorized,
}
func NotFoundError(prefixMessage string) *params.Error {
return ¶ms.Error{
Message: fmt.Sprintf("%s not found", prefixMessage),
Code: params.CodeNotFound,
}
}
func NotSupportedError(prefixMessage string) *params.Error {
return ¶ms.Error{
Message: fmt.Sprintf("%s not supported", prefixMessage),
Code: params.CodeNotSupported,
}
}
func NotProvisionedError(machineId string) *params.Error {
return ¶ms.Error{
Message: fmt.Sprintf("machine %s not provisioned", machineId),
Code: params.CodeNotProvisioned,
}
}
func NotAssignedError(unitName string) *params.Error {
return ¶ms.Error{
Message: fmt.Sprintf("unit %q is not assigned to a machine", unitName),
Code: params.CodeNotAssigned,
}
}
func AlreadyExistsError(what string) *params.Error {
return ¶ms.Error{
Message: fmt.Sprintf("%s already exists", what),
Code: params.CodeAlreadyExists,
}
}
func ServerError(message string) *params.Error {
return ¶ms.Error{
Message: message,
Code: "",
}
}
func PrefixedError(prefix, message string) *params.Error {
return ServerError(prefix + message)
}