MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / json_or_error

Method json_or_error

crates/cli/src/util.rs:99–112  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97 }
98
99 async fn json_or_error<T: serde::de::DeserializeOwned>(self) -> anyhow::Result<T> {
100 let status = self.status();
101 self.ensure_content_type("application/json")
102 .await?
103 .json()
104 .await
105 .map_err(|err| {
106 let mut err = anyhow::Error::from(err);
107 if let Some(desc) = err_status_desc(status) {
108 err = err.context(format!("malformed json payload for {desc} ({status})"))
109 }
110 err
111 })
112 }
113
114 fn found(self) -> Option<Self> {
115 (self.status() != http::StatusCode::NOT_FOUND).then_some(self)

Callers 7

module_defMethod · 0.80
spacetime_reverse_dnsFunction · 0.80
execute_publish_configsFunction · 0.80
call_pre_publishFunction · 0.80
execFunction · 0.80
execFunction · 0.80
select_databaseFunction · 0.80

Calls 4

err_status_descFunction · 0.85
statusMethod · 0.80
ensure_content_typeMethod · 0.80
jsonMethod · 0.45

Tested by

no test coverage detected