(json: bool, error: &impl Display)
| 102 | } |
| 103 | |
| 104 | pub fn encode_error(json: bool, error: &impl Display) -> Vec<u8> { |
| 105 | let error = format!("{error:#}"); |
| 106 | if json { |
| 107 | serde_json::to_string_pretty(&serde_json::json!({ "error": error })) |
| 108 | .unwrap_or_else(|_| r#"{"error": "failed to encode the error"}"#.to_string()) |
| 109 | .into_bytes() |
| 110 | } else { |
| 111 | encode_message_to_vec(&::prpc::server::ProtoError::new(error)) |
| 112 | } |
| 113 | } |
no outgoing calls
no test coverage detected