errortypes

package
v0.205.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 2 Imported by: 248

Documentation

Index

Constants

View Source
const (
	UnknownErrorCode = 999
	TimeoutErrorCode = iota
	BadInputErrorCode
	BlacklistedAppErrorCode
	BadServerResponseErrorCode
	FailedToRequestBidsErrorCode
	BidderTemporarilyDisabledErrorCode
	BlacklistedAcctErrorCode
	AcctRequiredErrorCode
	NoConversionRateErrorCode
)

Defines numeric codes for well-known errors.

View Source
const (
	UnknownWarningCode               = 10999
	InvalidPrivacyConsentWarningCode = iota + 10000
	AccountLevelDebugDisabledWarningCode
	BidderLevelDebugDisabledWarningCode
	DisabledCurrencyConversionWarningCode
)

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 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 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 BlacklistedAcct

type BlacklistedAcct struct {
	Message string
}

BlacklistedAcct should be used when a request account ID matches an entry in the BlacklistedAccts environment variable array

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

func (*BlacklistedAcct) Code

func (err *BlacklistedAcct) Code() int

func (*BlacklistedAcct) Error

func (err *BlacklistedAcct) Error() string

func (*BlacklistedAcct) Severity

func (err *BlacklistedAcct) 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 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 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 Warning

type Warning struct {
	Message     string
	WarningCode int
}

Warning is a generic non-fatal error.

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