Skip to content

Commit 5d8374b

Browse files
jordanhunt22Convex, Inc.
authored andcommitted
[Vanity Domains] Add http handlers for dashboard (#28112)
GitOrigin-RevId: f6d3496fa6e853152be70db6df8603f7f8d8ee9a
1 parent 79ab128 commit 5d8374b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crates/common/src/http/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ impl HttpError {
461461
.into_response()
462462
}
463463

464+
pub async fn error_message_from_bytes(
465+
bytes: hyper::body::Bytes,
466+
) -> (Cow<'static, str>, Cow<'static, str>) {
467+
let ResponseErrorMessage { code, message } =
468+
serde_json::from_slice(&bytes).expect("Couldn't deserialize as json");
469+
470+
(code, message)
471+
}
472+
464473
// Tests might parse a response back into a message
465474
#[cfg(any(test, feature = "testing"))]
466475
pub async fn from_response<B>(response: Response<B>) -> Self
@@ -469,12 +478,12 @@ impl HttpError {
469478
B::Error: fmt::Debug,
470479
{
471480
let (parts, body) = response.into_parts();
472-
let ResponseErrorMessage { code, message } = serde_json::from_slice(
473-
&hyper::body::to_bytes(body)
481+
let (code, message) = Self::error_message_from_bytes(
482+
hyper::body::to_bytes(body)
474483
.await
475484
.expect("Couldn't convert to bytes"),
476485
)
477-
.expect("Couldn't deserialize as json");
486+
.await;
478487

479488
Self {
480489
status_code: parts.status,

0 commit comments

Comments
 (0)