Skip to content

Commit 6f6a753

Browse files
committed
refactor(acp-nats): replace fallback byte literal with expect in error_response_bytes
Response::Error only contains integers, strings, and Option — serde_json serialization is infallible for this type. Replace the dead-code unwrap_or_else fallback string with an expect so the invariant is explicit and the raw JSON byte literal is gone. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
1 parent ae597a3 commit 6f6a753

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • rsworkspace/crates/acp-nats/src/client

rsworkspace/crates/acp-nats/src/client/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use trogon_std::time::GetElapsed;
1717

1818
fn error_response_bytes(id: RequestId, error: Error) -> Bytes {
1919
let msg = JsonRpcMessage::wrap(Response::<()>::Error { id, error });
20+
// Response<()>::Error only contains integers, strings, and Option — serialization is infallible.
2021
serde_json::to_vec(&msg)
21-
.unwrap_or_else(|_| br#"{"jsonrpc":"2.0","id":null,"error":{"code":-32603,"message":"failed to serialize error response"}}"#.to_vec())
22+
.expect("Response::Error serialization is infallible")
2223
.into()
2324
}
2425

0 commit comments

Comments
 (0)