github.com/prebid/prebid-server@v0.275.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 // BadInput should be used when returning errors which are caused by bad input. 24 // It should _not_ be used if the error is a server-side issue (e.g. failed to send the external request). 25 // 26 // BadInputs will not be written to the app log, since it's not an actionable item for the Prebid Server hosts. 27 type BadInput struct { 28 Message string 29 } 30 31 func (err *BadInput) Error() string { 32 return err.Message 33 } 34 35 func (err *BadInput) Code() int { 36 return BadInputErrorCode 37 } 38 39 func (err *BadInput) Severity() Severity { 40 return SeverityFatal 41 } 42 43 // BlacklistedApp should be used when a request App.ID matches an entry in the BlacklistedApps 44 // environment variable array 45 // 46 // These errors will be written to http.ResponseWriter before canceling execution 47 type BlacklistedApp struct { 48 Message string 49 } 50 51 func (err *BlacklistedApp) Error() string { 52 return err.Message 53 } 54 55 func (err *BlacklistedApp) Code() int { 56 return BlacklistedAppErrorCode 57 } 58 59 func (err *BlacklistedApp) Severity() Severity { 60 return SeverityFatal 61 } 62 63 // BlacklistedAcct should be used when a request account ID matches an entry in the BlacklistedAccts 64 // environment variable array 65 // 66 // These errors will be written to http.ResponseWriter before canceling execution 67 type BlacklistedAcct struct { 68 Message string 69 } 70 71 func (err *BlacklistedAcct) Error() string { 72 return err.Message 73 } 74 75 func (err *BlacklistedAcct) Code() int { 76 return BlacklistedAcctErrorCode 77 } 78 79 func (err *BlacklistedAcct) Severity() Severity { 80 return SeverityFatal 81 } 82 83 // AcctRequired should be used when the environment variable ACCOUNT_REQUIRED has been set to not 84 // process requests that don't come with a valid account ID 85 // 86 // These errors will be written to http.ResponseWriter before canceling execution 87 type AcctRequired struct { 88 Message string 89 } 90 91 func (err *AcctRequired) Error() string { 92 return err.Message 93 } 94 95 func (err *AcctRequired) Code() int { 96 return AcctRequiredErrorCode 97 } 98 99 func (err *AcctRequired) Severity() Severity { 100 return SeverityFatal 101 } 102 103 // BadServerResponse should be used when returning errors which are caused by bad/unexpected behavior on the remote server. 104 // 105 // For example: 106 // 107 // - The external server responded with a 500 108 // - The external server gave a malformed or unexpected response. 109 // 110 // These should not be used to log _connection_ errors (e.g. "couldn't find host"), 111 // which may indicate config issues for the PBS host company 112 type BadServerResponse struct { 113 Message string 114 } 115 116 func (err *BadServerResponse) Error() string { 117 return err.Message 118 } 119 120 func (err *BadServerResponse) Code() int { 121 return BadServerResponseErrorCode 122 } 123 124 func (err *BadServerResponse) Severity() Severity { 125 return SeverityFatal 126 } 127 128 // FailedToRequestBids is an error to cover the case where an adapter failed to generate any http requests to get bids, 129 // but did not generate any error messages. This should not happen in practice and will signal that an adapter is poorly 130 // coded. If there was something wrong with a request such that an adapter could not generate a bid, then it should 131 // generate an error explaining the deficiency. Otherwise it will be extremely difficult to debug the reason why an 132 // adapter is not bidding. 133 type FailedToRequestBids struct { 134 Message string 135 } 136 137 func (err *FailedToRequestBids) Error() string { 138 return err.Message 139 } 140 141 func (err *FailedToRequestBids) Code() int { 142 return FailedToRequestBidsErrorCode 143 } 144 145 func (err *FailedToRequestBids) Severity() Severity { 146 return SeverityFatal 147 } 148 149 // BidderTemporarilyDisabled is used at the request validation step, where we want to continue processing as best we 150 // can rather than returning a 4xx, and still return an error message. 151 // The initial usecase is to flag deprecated bidders. 152 type BidderTemporarilyDisabled struct { 153 Message string 154 } 155 156 func (err *BidderTemporarilyDisabled) Error() string { 157 return err.Message 158 } 159 160 func (err *BidderTemporarilyDisabled) Code() int { 161 return BidderTemporarilyDisabledErrorCode 162 } 163 164 func (err *BidderTemporarilyDisabled) Severity() Severity { 165 return SeverityWarning 166 } 167 168 // MalformedAcct should be used when the retrieved account config cannot be unmarshaled 169 // These errors will be written to http.ResponseWriter before canceling execution 170 type MalformedAcct struct { 171 Message string 172 } 173 174 func (err *MalformedAcct) Error() string { 175 return err.Message 176 } 177 178 func (err *MalformedAcct) Code() int { 179 return MalformedAcctErrorCode 180 } 181 182 func (err *MalformedAcct) Severity() Severity { 183 return SeverityFatal 184 } 185 186 // Warning is a generic non-fatal error. Throughout the codebase, an error can 187 // only be a warning if it's of the type defined below 188 type Warning struct { 189 Message string 190 WarningCode int 191 } 192 193 func (err *Warning) Error() string { 194 return err.Message 195 } 196 197 func (err *Warning) Code() int { 198 return err.WarningCode 199 } 200 201 func (err *Warning) Severity() Severity { 202 return SeverityWarning 203 }