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

Function response

crates/pg/src/pg_server.rs:121–143  ·  view source on GitHub ↗
(res: axum::response::Result<T>, database: &str)

Source from the content-addressed store, hash-verified

119}
120
121async fn response<T>(res: axum::response::Result<T>, database: &str) -> Result<T, PgError> {
122 match res.map(ResponseWrapper) {
123 Ok(sql) => Ok(sql.0),
124 err => {
125 let res = err.into_response();
126 if res.status() == StatusCode::NOT_FOUND {
127 log::error!("PG: Database not found: {database}");
128 return Err(PgWireError::UserError(Box::new(ErrorInfo::new(
129 "FATAL".to_string(),
130 "3D000".to_string(),
131 format!("database \"{database}\" does not exist"),
132 )))
133 .into());
134 }
135 let bytes = to_bytes(res.into_body(), usize::MAX)
136 .await
137 .map_err(|err| PgWireError::ApiError(Box::new(err)))?;
138 let err = String::from_utf8_lossy(&bytes);
139 log::error!("PG: Error for database {database}: {err}");
140 Err(PgError::Sql(format!("{err}")))
141 }
142 }
143}
144
145struct PgSpacetimeDB<T> {
146 ctx: T,

Callers 2

exe_sqlMethod · 0.85
on_startupMethod · 0.85

Calls 8

statusMethod · 0.80
OkFunction · 0.50
ErrFunction · 0.50
newFunction · 0.50
to_bytesFunction · 0.50
mapMethod · 0.45
into_responseMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…