github.com/prebid/prebid-server/v2@v2.18.0/errortypes/errortypes.go (about)

     1  package errortypes
     2  
     3  // Timeout should be used to flag that a bidder failed to return a response because the PBS timeout timer
     4  // expired before a result was received.
     5  //
     6  // Timeouts will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.
     7  type Timeout struct {
     8  	Message string
     9  }
    10  
    11  func (err *Timeout) Error() string {
    12  	return err.Message
    13  }
    14  
    15  func (err *Timeout) Code() int {
    16  	return TimeoutErrorCode
    17  }
    18  
    19  func (err *Timeout) Severity() Severity {
    20  	return SeverityFatal
    21  }
    22  
    23  // TmaxTimeout should be used to flag that remaining tmax duration is not enough to get response from bidder
    24  //
    25  // TmaxTimeout will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.
    26  type TmaxTimeout struct {
    27  	Message string
    28  }
    29  
    30  func (err *TmaxTimeout) Error() string {
    31  	return err.Message
    32  }
    33  
    34  func (err *TmaxTimeout) Code() int {
    35  	return TmaxTimeoutErrorCode
    36  }
    37  
    38  func (err *TmaxTimeout) Severity() Severity {
    39  	return SeverityFatal
    40  }
    41  
    42  // BadInput should be used when returning errors which are caused by bad input.
    43  // It should _not_ be used if the error is a server-side issue (e.g. failed to send the external request).
    44  //
    45  // BadInputs will not be written to the app log, since it's not an actionable item for the Prebid Server hosts.
    46  type BadInput struct {
    47  	Message string
    48  }
    49  
    50  func (err *BadInput) Error() string {
    51  	return err.Message
    52  }
    53  
    54  func (err *BadInput) Code() int {
    55  	return BadInputErrorCode
    56  }
    57  
    58  func (err *BadInput) Severity() Severity {
    59  	return SeverityFatal
    60  }
    61  
    62  // BlacklistedApp should be used when a request App.ID matches an entry in the BlacklistedApps
    63  // environment variable array
    64  //
    65  // These errors will be written to  http.ResponseWriter before canceling execution
    66  type BlacklistedApp struct {
    67  	Message string
    68  }
    69  
    70  func (err *BlacklistedApp) Error() string {
    71  	return err.Message
    72  }
    73  
    74  func (err *BlacklistedApp) Code() int {
    75  	return BlacklistedAppErrorCode
    76  }
    77  
    78  func (err *BlacklistedApp) Severity() Severity {
    79  	return SeverityFatal
    80  }
    81  
    82  // AccountDisabled should be used when a request an account is specifically disabled in account config.
    83  type AccountDisabled struct {
    84  	Message string
    85  }
    86  
    87  func (err *AccountDisabled) Error() string {
    88  	return err.Message
    89  }
    90  
    91  func (err *AccountDisabled) Code() int {
    92  	return AccountDisabledErrorCode
    93  }
    94  
    95  func (err *AccountDisabled) Severity() Severity {
    96  	return SeverityFatal
    97  }
    98  
    99  // AcctRequired should be used when the environment variable ACCOUNT_REQUIRED has been set to not
   100  // process requests that don't come with a valid account ID
   101  //
   102  // These errors will be written to  http.ResponseWriter before canceling execution
   103  type AcctRequired struct {
   104  	Message string
   105  }
   106  
   107  func (err *AcctRequired) Error() string {
   108  	return err.Message
   109  }
   110  
   111  func (err *AcctRequired) Code() int {
   112  	return AcctRequiredErrorCode
   113  }
   114  
   115  func (err *AcctRequired) Severity() Severity {
   116  	return SeverityFatal
   117  }
   118  
   119  // BadServerResponse should be used when returning errors which are caused by bad/unexpected behavior on the remote server.
   120  //
   121  // For example:
   122  //
   123  //   - The external server responded with a 500
   124  //   - The external server gave a malformed or unexpected response.
   125  //
   126  // These should not be used to log _connection_ errors (e.g. "couldn't find host"),
   127  // which may indicate config issues for the PBS host company
   128  type BadServerResponse struct {
   129  	Message string
   130  }
   131  
   132  func (err *BadServerResponse) Error() string {
   133  	return err.Message
   134  }
   135  
   136  func (err *BadServerResponse) Code() int {
   137  	return BadServerResponseErrorCode
   138  }
   139  
   140  func (err *BadServerResponse) Severity() Severity {
   141  	return SeverityFatal
   142  }
   143  
   144  // FailedToRequestBids is an error to cover the case where an adapter failed to generate any http requests to get bids,
   145  // but did not generate any error messages. This should not happen in practice and will signal that an adapter is poorly
   146  // coded. If there was something wrong with a request such that an adapter could not generate a bid, then it should
   147  // generate an error explaining the deficiency. Otherwise it will be extremely difficult to debug the reason why an
   148  // adapter is not bidding.
   149  type FailedToRequestBids struct {
   150  	Message string
   151  }
   152  
   153  func (err *FailedToRequestBids) Error() string {
   154  	return err.Message
   155  }
   156  
   157  func (err *FailedToRequestBids) Code() int {
   158  	return FailedToRequestBidsErrorCode
   159  }
   160  
   161  func (err *FailedToRequestBids) Severity() Severity {
   162  	return SeverityFatal
   163  }
   164  
   165  // BidderTemporarilyDisabled is used at the request validation step, where we want to continue processing as best we
   166  // can rather than returning a 4xx, and still return an error message.
   167  // The initial usecase is to flag deprecated bidders.
   168  type BidderTemporarilyDisabled struct {
   169  	Message string
   170  }
   171  
   172  func (err *BidderTemporarilyDisabled) Error() string {
   173  	return err.Message
   174  }
   175  
   176  func (err *BidderTemporarilyDisabled) Code() int {
   177  	return BidderTemporarilyDisabledErrorCode
   178  }
   179  
   180  func (err *BidderTemporarilyDisabled) Severity() Severity {
   181  	return SeverityWarning
   182  }
   183  
   184  // MalformedAcct should be used when the retrieved account config cannot be unmarshaled
   185  // These errors will be written to http.ResponseWriter before canceling execution
   186  type MalformedAcct struct {
   187  	Message string
   188  }
   189  
   190  func (err *MalformedAcct) Error() string {
   191  	return err.Message
   192  }
   193  
   194  func (err *MalformedAcct) Code() int {
   195  	return MalformedAcctErrorCode
   196  }
   197  
   198  func (err *MalformedAcct) Severity() Severity {
   199  	return SeverityFatal
   200  }
   201  
   202  // Warning is a generic non-fatal error. Throughout the codebase, an error can
   203  // only be a warning if it's of the type defined below
   204  type Warning struct {
   205  	Message     string
   206  	WarningCode int
   207  }
   208  
   209  func (err *Warning) Error() string {
   210  	return err.Message
   211  }
   212  
   213  func (err *Warning) Code() int {
   214  	return err.WarningCode
   215  }
   216  
   217  func (err *Warning) Severity() Severity {
   218  	return SeverityWarning
   219  }
   220  
   221  // FailedToUnmarshal should be used to represent errors that occur when unmarshaling raw json.
   222  type FailedToUnmarshal struct {
   223  	Message string
   224  }
   225  
   226  func (err *FailedToUnmarshal) Error() string {
   227  	return err.Message
   228  }
   229  
   230  func (err *FailedToUnmarshal) Code() int {
   231  	return FailedToUnmarshalErrorCode
   232  }
   233  
   234  func (err *FailedToUnmarshal) Severity() Severity {
   235  	return SeverityFatal
   236  }
   237  
   238  // FailedToMarshal should be used to represent errors that occur when marshaling to a byte slice.
   239  type FailedToMarshal struct {
   240  	Message string
   241  }
   242  
   243  func (err *FailedToMarshal) Error() string {
   244  	return err.Message
   245  }
   246  
   247  func (err *FailedToMarshal) Code() int {
   248  	return FailedToMarshalErrorCode
   249  }
   250  
   251  func (err *FailedToMarshal) Severity() Severity {
   252  	return SeverityFatal
   253  }
   254  
   255  // DebugWarning is a generic non-fatal error used in debug mode. Throughout the codebase, an error can
   256  // only be a warning if it's of the type defined below
   257  type DebugWarning struct {
   258  	Message     string
   259  	WarningCode int
   260  }
   261  
   262  func (err *DebugWarning) Error() string {
   263  	return err.Message
   264  }
   265  
   266  func (err *DebugWarning) Code() int {
   267  	return err.WarningCode
   268  }
   269  
   270  func (err *DebugWarning) Severity() Severity {
   271  	return SeverityWarning
   272  }
   273  
   274  func (err *DebugWarning) Scope() Scope {
   275  	return ScopeDebug
   276  }