(resp: &JsonRpcResponse)
| 655 | } |
| 656 | |
| 657 | fn serialize_response_line(resp: &JsonRpcResponse) -> String { |
| 658 | match serde_json::to_string(resp) { |
| 659 | Ok(line) => line, |
| 660 | Err(e) => { |
| 661 | eprintln!("failed to serialize response: {e}"); |
| 662 | let fallback = JsonRpcResponse::error_with_data( |
| 663 | resp.id.clone(), |
| 664 | ErrorCode::InternalError, |
| 665 | "failed to serialize JSON-RPC response".to_string(), |
| 666 | Some(json!({ |
| 667 | "reason_code": "response_serialization_failed", |
| 668 | "detail": e.to_string(), |
| 669 | })), |
| 670 | ); |
| 671 | serde_json::to_string(&fallback).unwrap_or_else(|fallback_err| { |
| 672 | hardcoded_internal_error_response(&resp.id, &fallback_err.to_string()) |
| 673 | }) |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | /// Cached result of a latest-version check against GitHub releases. |
| 679 | struct VersionCheckState { |
no test coverage detected