Skip to content

Commit

Permalink
Don't realloc on error
Browse files Browse the repository at this point in the history
  • Loading branch information
randomairborne committed Jun 6, 2024
1 parent e5c220c commit d66a419
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ pub enum Error {

impl IntoResponse for Error {
fn into_response(self) -> Response {
(StatusCode::INTERNAL_SERVER_ERROR, self.to_string()).into_response()
let msg = match self {
Error::NoHeader => "No header found",
Error::ConnectInfo => "Could not extract connection info",
Error::NoNonce => "Could not getc CSP nonce",
Error::ToStr(_) => {
"Could not convert supplied header to string (this is a configuration issue)"
}
Error::ToAddr(_) => {
"Could not convert supplied header to IP address (this is a configuration issue)"
}
};
(StatusCode::INTERNAL_SERVER_ERROR, msg).into_response()
}
}

0 comments on commit d66a419

Please sign in to comment.