-
Notifications
You must be signed in to change notification settings - Fork 4
/
errors.go
69 lines (53 loc) · 1.67 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
package limacharlie
import (
"errors"
"fmt"
"strings"
)
type lcErrorCode = string
const (
lcErrClientNoOptionsLoader = "CLIENT_NO_OPTION_LOADER"
lcErrClientMissingRequirements = "CLIENT_MISSING_REQUIREMENTS"
)
type lcError struct {
code lcErrorCode
}
func newLCError(code lcErrorCode) *lcError {
return &lcError{
code: code,
}
}
func (e *lcError) Error() string {
return fmt.Sprintf("limacharlie client: %s", e.code)
}
// InvalidClientOptionsError is the error type returned by Client
type InvalidClientOptionsError struct {
s string
}
// NewInvalidClientOptionsError makes a new error
func NewInvalidClientOptionsError(err string) InvalidClientOptionsError {
return InvalidClientOptionsError{s: err}
}
func (e InvalidClientOptionsError) Error() string {
return fmt.Sprintf("invalid client options: %s", e.s)
}
// ErrorNoAPIKeyConfigured is returned when no api key is given to a client
var ErrorNoAPIKeyConfigured = errors.New("no api key configured")
// RESTError is a generic rest error
type RESTError struct {
s string
}
// NewRESTError makes a new RESTError
func NewRESTError(err string) RESTError {
return RESTError{s: err}
}
func (e RESTError) Error() string {
return fmt.Sprintf("api error: %s", e.s)
}
// ErrorResourceNotFound is returned when querying for a resource that does not exist or that the client does not have the permission to see
var ErrorResourceNotFound = errors.New("resource not found")
// Returned for a feature that is not yet implemented to parity with the Python SDK.
var ErrorNotImplemented = errors.New("not implemented")
func IsServiceNotRegisteredError(err error) bool {
return strings.Contains(err.Error(), "org not registered to service")
}