-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
54 lines (47 loc) · 2.41 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
package sergel
import "errors"
var (
ErrBadCountryCode = errors.New("bad country code")
ErrInvalidSender = errors.New("the specified sender is invalid")
ErrInvalidReceiver = errors.New("the specified receiver is invalid")
ErrInvalidMessage = errors.New("the specified message is invalid")
ErrInvalidUsername = errors.New("the specified username is invalid")
ErrInvalidPassword = errors.New("the specified password is invalid")
ErrInvalidPlatformID = errors.New("the speficied platform id is invalid")
ErrInvalidPlatformPartnerID = errors.New("the specified platform partner id is invalid")
ErrInvalidBaseURL = errors.New("the specified URL is invalid")
)
var (
ErrUnknown = errors.New("unknown error, please contact support and include your whole transaction")
ErrInvalidAuthentication = errors.New("invalid authentication, please check your username and password")
ErrAccessDenied = errors.New("access denied, please check your username and password")
ErrInvalidOrMissingPlatformID = errors.New("invalid or missing platform id")
ErrInvalidOrMissingPlatformPartnerID = errors.New("invalid or missing platform partner id")
ErrInvalidOrMissingCurrencyForPremiumMessage = errors.New("invalid or missing currency for premium message")
ErrNoGatesAvailable = errors.New("no gates available, contact support and include your whole transaction")
ErrSpecifiedGateUnavailable = errors.New("specififed gate unavailable")
ErrUnableToAccessCredentials = errors.New("unable to access SMSC credentials")
)
var sergelErrMap = map[int]error{
106000: ErrUnknown,
106100: ErrInvalidAuthentication,
106101: ErrAccessDenied,
106102: ErrUnableToAccessCredentials,
106200: ErrInvalidOrMissingPlatformID,
106201: ErrInvalidOrMissingPlatformPartnerID,
106202: ErrInvalidOrMissingCurrencyForPremiumMessage,
106300: ErrNoGatesAvailable,
106301: ErrSpecifiedGateUnavailable,
}
// isSergelError returns true if the provided result
// code can be mapped to a Sergel API error which is
// recognized by go-sergel.
func isSergelError(resultCode int) bool {
_, exists := sergelErrMap[resultCode]
return exists
}
// sergelErr returns the error corresponding to the
// provided resultCode.
func sergelErr(resultCode int) error {
return sergelErrMap[resultCode]
}