MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / encode_error

Function encode_error

ra-rpc/src/lib.rs:104–113  ·  view source on GitHub ↗
(json: bool, error: &impl Display)

Source from the content-addressed store, hash-verified

102}
103
104pub 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}

Callers 2

handleMethod · 0.85
dispatch_prpcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected