From a27e94705970ee84caa99eac8ce24b141ac7b8d8 Mon Sep 17 00:00:00 2001 From: Aleksei Voronov Date: Sun, 17 Nov 2024 19:29:31 +0100 Subject: [PATCH] Bring back handling RecordNotFound Apparently this can also happen. It's all weird, but eh, let's just handle that too --- src/services/bluesky/client.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/services/bluesky/client.rs b/src/services/bluesky/client.rs index 30c6414..88f6615 100644 --- a/src/services/bluesky/client.rs +++ b/src/services/bluesky/client.rs @@ -115,6 +115,7 @@ impl Bluesky { let profile_output = match result { Ok(profile_output) => profile_output, Err(e) if is_missing_repo_error(&e) => return Ok(None), + Err(e) if is_record_not_found_error(&e) => return Ok(None), Err(e) => return Err(e.into()), }; @@ -197,6 +198,29 @@ where ) } +fn is_record_not_found_error(error: &atrium_xrpc::error::Error) -> bool +where + T: Debug, +{ + use atrium_xrpc::error::{Error, ErrorResponseBody, XrpcError, XrpcErrorKind}; + + matches!(error, + Error::XrpcResponse(XrpcError { + status, + error: + Some(XrpcErrorKind::Undefined(ErrorResponseBody { + error: Some(error_code), + message: Some(error_message), + })), + }) if + // FIXME: This is this way instead of pattern matching because atrium's + // version of http is pegged at like 0.2.x and it does not + // re-export it so we have no way of referencing the real type + status.as_u16() == StatusCode::BAD_REQUEST.as_u16() + && error_code == "RecordNotFound" + ) +} + fn is_unable_to_resolve_handle_error(error: &atrium_xrpc::error::Error) -> bool where T: Debug,