@@ -257,12 +257,45 @@ mod tests {
257257 ) ,
258258 ] ;
259259
260+ // `mapped_status` is an exhaustive match with no `_` arm, so adding a
261+ // new `TrustedServerError` variant fails to compile here until its
262+ // status is declared — the per-variant coverage can't silently go
263+ // stale. Cross-checking it against the independent `cases` literals
264+ // above guards both encodings against drift.
265+ fn mapped_status ( error : & TrustedServerError ) -> StatusCode {
266+ match error {
267+ TrustedServerError :: BadRequest { .. } => StatusCode :: BAD_REQUEST ,
268+ TrustedServerError :: Configuration { .. } | TrustedServerError :: Settings { .. } => {
269+ StatusCode :: INTERNAL_SERVER_ERROR
270+ }
271+ TrustedServerError :: Auction { .. } => StatusCode :: BAD_GATEWAY ,
272+ TrustedServerError :: Gam { .. } => StatusCode :: BAD_GATEWAY ,
273+ TrustedServerError :: GdprConsent { .. } => StatusCode :: BAD_REQUEST ,
274+ TrustedServerError :: InvalidUtf8 { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
275+ TrustedServerError :: InvalidHeaderValue { .. } => StatusCode :: BAD_REQUEST ,
276+ TrustedServerError :: KvStore { .. } => StatusCode :: SERVICE_UNAVAILABLE ,
277+ TrustedServerError :: Prebid { .. } => StatusCode :: BAD_GATEWAY ,
278+ TrustedServerError :: Integration { .. } => StatusCode :: BAD_GATEWAY ,
279+ TrustedServerError :: Proxy { .. } => StatusCode :: BAD_GATEWAY ,
280+ TrustedServerError :: Forbidden { .. } => StatusCode :: FORBIDDEN ,
281+ TrustedServerError :: AllowlistViolation { .. } => StatusCode :: FORBIDDEN ,
282+ TrustedServerError :: EdgeCookie { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
283+ TrustedServerError :: PartnerNotFound { .. } => StatusCode :: NOT_FOUND ,
284+ TrustedServerError :: InsecureDefault { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
285+ }
286+ }
287+
260288 for ( error, expected_status) in cases {
261289 assert_eq ! (
262290 error. status_code( ) ,
263291 expected_status,
264292 "should map {error:?} to {expected_status}" ,
265293 ) ;
294+ assert_eq ! (
295+ mapped_status( & error) ,
296+ expected_status,
297+ "exhaustive mapping should agree with the table for {error:?}" ,
298+ ) ;
266299 }
267300 }
268301
0 commit comments