log erroring errors; improve inspection functors.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
4718387dbe
commit
158de10fe6
3 changed files with 40 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
use axum::response::{IntoResponse, Response};
|
||||
use bytes::BytesMut;
|
||||
use conduit::Error;
|
||||
use conduit::{error, Error};
|
||||
use http::StatusCode;
|
||||
use http_body_util::Full;
|
||||
use ruma::api::{client::uiaa::UiaaResponse, OutgoingResponse};
|
||||
|
@ -13,9 +13,12 @@ impl From<Error> for RumaResponse<UiaaResponse> {
|
|||
|
||||
impl<T: OutgoingResponse> IntoResponse for RumaResponse<T> {
|
||||
fn into_response(self) -> Response {
|
||||
match self.0.try_into_http_response::<BytesMut>() {
|
||||
Ok(res) => res.map(BytesMut::freeze).map(Full::new).into_response(),
|
||||
Err(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
}
|
||||
self.0
|
||||
.try_into_http_response::<BytesMut>()
|
||||
.inspect_err(|e| error!("response error: {e}"))
|
||||
.map_or_else(
|
||||
|_| StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
|r| r.map(BytesMut::freeze).map(Full::new).into_response(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue