-
Notifications
You must be signed in to change notification settings - Fork 739
/
code.go
49 lines (45 loc) · 1.19 KB
/
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
42
43
44
45
46
47
48
49
package errortypes
// Defines numeric codes for well-known errors.
const (
UnknownErrorCode = 999
TimeoutErrorCode = iota
BadInputErrorCode
BlacklistedAppErrorCode
BadServerResponseErrorCode
FailedToRequestBidsErrorCode
BidderTemporarilyDisabledErrorCode
AccountDisabledErrorCode
AcctRequiredErrorCode
NoConversionRateErrorCode
MalformedAcctErrorCode
ModuleRejectionErrorCode
TmaxTimeoutErrorCode
FailedToMarshalErrorCode
FailedToUnmarshalErrorCode
)
// Defines numeric codes for well-known warnings.
const (
UnknownWarningCode = 10999
InvalidPrivacyConsentWarningCode = iota + 10000
AccountLevelDebugDisabledWarningCode
BidderLevelDebugDisabledWarningCode
DisabledCurrencyConversionWarningCode
AlternateBidderCodeWarningCode
MultiBidWarningCode
AdServerTargetingWarningCode
BidAdjustmentWarningCode
FloorBidRejectionWarningCode
InvalidBidResponseDSAWarningCode
)
// 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
}