Skip to content

Commit

Permalink
just panic
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Nov 25, 2024
1 parent a3ee555 commit 9d99131
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions dropshot/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,20 @@ impl HandlerError {
rsp.headers_mut()
.insert(crate::HEADER_REQUEST_ID, header);
}
// This should never happen, but let's not panic in release
// mode if it does.
Err(e) if cfg!(debug_assertions) => {
unreachable!("request ID {request_id:?} is not a valid HeaderValue: {e}");
// We should never generate a request ID that contains
// invalid characters, but sadly, we can't promise that
// here...
//
// Note that this is morally equivalent to an `expect`, but
// the match is a bit nicer as it lets us include the
// request ID that `HeaderValue::from_str` didn't like in
// the panic message.
Err(e) => {
unreachable!(
"request ID {request_id:?} is not a valid \
HeaderValue: {e}",
);
}
Err(_) => {}
}

rsp
Expand Down

0 comments on commit 9d99131

Please sign in to comment.