-
Notifications
You must be signed in to change notification settings - Fork 738
/
code.go
41 lines (37 loc) · 1000 Bytes
/
code.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
package errortypes
// Defines numeric codes for well-known errors.
const (
UnknownErrorCode = 999
TimeoutErrorCode = iota
BadInputErrorCode
BlacklistedAppErrorCode
BadServerResponseErrorCode
FailedToRequestBidsErrorCode
BidderTemporarilyDisabledErrorCode
BlacklistedAcctErrorCode
AcctRequiredErrorCode
NoConversionRateErrorCode
MalformedAcctErrorCode
ModuleRejectionErrorCode
)
// Defines numeric codes for well-known warnings.
const (
UnknownWarningCode = 10999
InvalidPrivacyConsentWarningCode = iota + 10000
AccountLevelDebugDisabledWarningCode
BidderLevelDebugDisabledWarningCode
DisabledCurrencyConversionWarningCode
AlternateBidderCodeWarningCode
)
// Coder provides an error or warning code with severity.
type Coder interface {
Code() int
Severity() Severity
}
// ReadCode returns the error or warning code, or UnknownErrorCode if unavailable.
func ReadCode(err error) int {
if e, ok := err.(Coder); ok {
return e.Code()
}
return UnknownErrorCode
}