errortypes

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownErrorCode = 999
	TimeoutErrorCode = iota
	BadInputErrorCode
	BlacklistedAppErrorCode
	BadServerResponseErrorCode
	FailedToRequestBidsErrorCode
	BidderTemporarilyDisabledErrorCode
	AccountDisabledErrorCode
	AcctRequiredErrorCode
	NoConversionRateErrorCode
	MalformedAcctErrorCode
	ModuleRejectionErrorCode
	TmaxTimeoutErrorCode
	FailedToMarshalErrorCode
	FailedToUnmarshalErrorCode
)

Defines numeric codes for well-known errors.

View Source
const (
	UnknownWarningCode               = 10999
	InvalidPrivacyConsentWarningCode = iota + 10000
	AccountLevelDebugDisabledWarningCode
	BidderLevelDebugDisabledWarningCode
	DisabledCurrencyConversionWarningCode
	AlternateBidderCodeWarningCode
	MultiBidWarningCode
	AdServerTargetingWarningCode
	BidAdjustmentWarningCode
	FloorBidRejectionWarningCode
)

Defines numeric codes for well-known warnings.

Variables

This section is empty.

Functions

func ContainsFatalError

func ContainsFatalError(errors []error) bool

ContainsFatalError checks if the error list contains a fatal error.

func FatalOnly

func FatalOnly(errs []error) []error

FatalOnly returns a new error list with only the fatal severity errors.

func IsWarning

func IsWarning(err error) bool

IsWarning returns true if an error is labeled with a Severity of SeverityWarning Throughout the codebase, errors with SeverityWarning are of the type Warning defined in this package

func ReadCode

func ReadCode(err error) int

ReadCode returns the error or warning code, or UnknownErrorCode if unavailable.

func WarningOnly

func WarningOnly(errs []error) []error

WarningOnly returns a new error list with only the warning severity errors.

Types

type AccountDisabled

type AccountDisabled struct {
	Message string
}

AccountDisabled should be used when a request an account is specifically disabled in account config.

func (*AccountDisabled) Code

func (err *AccountDisabled) Code() int

func (*AccountDisabled) Error

func (err *AccountDisabled) Error() string

func (*AccountDisabled) Severity

func (err *AccountDisabled) Severity() Severity

type AcctRequired

type AcctRequired struct {
	Message string
}

AcctRequired should be used when the environment variable ACCOUNT_REQUIRED has been set to not process requests that don't come with a valid account ID

These errors will be written to http.ResponseWriter before canceling execution

func (*AcctRequired) Code

func (err *AcctRequired) Code() int

func (*AcctRequired) Error

func (err *AcctRequired) Error() string

func (*AcctRequired) Severity

func (err *AcctRequired) Severity() Severity

type AggregateError

type AggregateError struct {
	Message string
	Errors  []error
}

AggregateError represents one or more errors.

func NewAggregateError

func NewAggregateError(msg string, errs []error) AggregateError

NewAggregateError builds a AggregateError struct.

func (AggregateError) Error

func (e AggregateError) Error() string

Error implements the standard error interface.

type BadInput

type BadInput struct {
	Message string
}

BadInput should be used when returning errors which are caused by bad input. It should _not_ be used if the error is a server-side issue (e.g. failed to send the external request).

BadInputs will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.

func (*BadInput) Code

func (err *BadInput) Code() int

func (*BadInput) Error

func (err *BadInput) Error() string

func (*BadInput) Severity

func (err *BadInput) Severity() Severity

type BadServerResponse

type BadServerResponse struct {
	Message string
}

BadServerResponse should be used when returning errors which are caused by bad/unexpected behavior on the remote server.

For example:

  • The external server responded with a 500
  • The external server gave a malformed or unexpected response.

These should not be used to log _connection_ errors (e.g. "couldn't find host"), which may indicate config issues for the PBS host company

func (*BadServerResponse) Code

func (err *BadServerResponse) Code() int

func (*BadServerResponse) Error

func (err *BadServerResponse) Error() string

func (*BadServerResponse) Severity

func (err *BadServerResponse) Severity() Severity

type BidderTemporarilyDisabled

type BidderTemporarilyDisabled struct {
	Message string
}

BidderTemporarilyDisabled is used at the request validation step, where we want to continue processing as best we can rather than returning a 4xx, and still return an error message. The initial usecase is to flag deprecated bidders.

func (*BidderTemporarilyDisabled) Code

func (err *BidderTemporarilyDisabled) Code() int

func (*BidderTemporarilyDisabled) Error

func (err *BidderTemporarilyDisabled) Error() string

func (*BidderTemporarilyDisabled) Severity

func (err *BidderTemporarilyDisabled) Severity() Severity

type BlacklistedApp

type BlacklistedApp struct {
	Message string
}

BlacklistedApp should be used when a request App.ID matches an entry in the BlacklistedApps environment variable array

These errors will be written to http.ResponseWriter before canceling execution

func (*BlacklistedApp) Code

func (err *BlacklistedApp) Code() int

func (*BlacklistedApp) Error

func (err *BlacklistedApp) Error() string

func (*BlacklistedApp) Severity

func (err *BlacklistedApp) Severity() Severity

type Coder

type Coder interface {
	Code() int
	Severity() Severity
}

Coder provides an error or warning code with severity.

type FailedToMarshal

type FailedToMarshal struct {
	Message string
}

FailedToMarshal should be used to represent errors that occur when marshaling to a byte slice.

func (*FailedToMarshal) Code

func (err *FailedToMarshal) Code() int

func (*FailedToMarshal) Error

func (err *FailedToMarshal) Error() string

func (*FailedToMarshal) Severity

func (err *FailedToMarshal) Severity() Severity

type FailedToRequestBids

type FailedToRequestBids struct {
	Message string
}

FailedToRequestBids is an error to cover the case where an adapter failed to generate any http requests to get bids, but did not generate any error messages. This should not happen in practice and will signal that an adapter is poorly coded. If there was something wrong with a request such that an adapter could not generate a bid, then it should generate an error explaining the deficiency. Otherwise it will be extremely difficult to debug the reason why an adapter is not bidding.

func (*FailedToRequestBids) Code

func (err *FailedToRequestBids) Code() int

func (*FailedToRequestBids) Error

func (err *FailedToRequestBids) Error() string

func (*FailedToRequestBids) Severity

func (err *FailedToRequestBids) Severity() Severity

type FailedToUnmarshal

type FailedToUnmarshal struct {
	Message string
}

FailedToUnmarshal should be used to represent errors that occur when unmarshaling raw json.

func (*FailedToUnmarshal) Code

func (err *FailedToUnmarshal) Code() int

func (*FailedToUnmarshal) Error

func (err *FailedToUnmarshal) Error() string

func (*FailedToUnmarshal) Severity

func (err *FailedToUnmarshal) Severity() Severity

type MalformedAcct

type MalformedAcct struct {
	Message string
}

MalformedAcct should be used when the retrieved account config cannot be unmarshaled These errors will be written to http.ResponseWriter before canceling execution

func (*MalformedAcct) Code

func (err *MalformedAcct) Code() int

func (*MalformedAcct) Error

func (err *MalformedAcct) Error() string

func (*MalformedAcct) Severity

func (err *MalformedAcct) Severity() Severity

type Severity

type Severity int

Severity represents the severity level of a bid processing error.

const (
	// SeverityUnknown represents an unknown severity level.
	SeverityUnknown Severity = iota

	// SeverityFatal represents a fatal bid processing error which prevents a bid response.
	SeverityFatal

	// SeverityWarning represents a non-fatal bid processing error where invalid or ambiguous
	// data in the bid request was ignored.
	SeverityWarning
)

type Timeout

type Timeout struct {
	Message string
}

Timeout should be used to flag that a bidder failed to return a response because the PBS timeout timer expired before a result was received.

Timeouts will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.

func (*Timeout) Code

func (err *Timeout) Code() int

func (*Timeout) Error

func (err *Timeout) Error() string

func (*Timeout) Severity

func (err *Timeout) Severity() Severity

type TmaxTimeout

type TmaxTimeout struct {
	Message string
}

TmaxTimeout should be used to flag that remaining tmax duration is not enough to get response from bidder

TmaxTimeout will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.

func (*TmaxTimeout) Code

func (err *TmaxTimeout) Code() int

func (*TmaxTimeout) Error

func (err *TmaxTimeout) Error() string

func (*TmaxTimeout) Severity

func (err *TmaxTimeout) Severity() Severity

type Warning

type Warning struct {
	Message     string
	WarningCode int
}

Warning is a generic non-fatal error. Throughout the codebase, an error can only be a warning if it's of the type defined below

func (*Warning) Code

func (err *Warning) Code() int

func (*Warning) Error

func (err *Warning) Error() string

func (*Warning) Severity

func (err *Warning) Severity() Severity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL