Skip to content

Commit

Permalink
Add response status code to `FetchApiRootUrlError.ApiRootLinkHeaderNo…
Browse files Browse the repository at this point in the history
…tFound` (#247)
  • Loading branch information
oguzkocer authored Aug 8, 2024
1 parent 28dac79 commit 1680f77
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions wp_api/src/login/url_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl StateParsedUrl {
}),
None => Err(FetchApiRootUrlError::ApiRootLinkHeaderNotFound {
header_map: response.header_map,
status_code: response.status_code,
}),
}
}
Expand Down Expand Up @@ -180,16 +181,23 @@ pub(super) struct StateFetchedApiDetails {
#[derive(Debug, thiserror::Error, uniffi::Error)]
pub enum FetchApiRootUrlError {
#[error(
"Request execution failed!\nStatus Code: '{:?}'.\nResponse: '{}'",
"Request execution failed!\nStatus Code: '{:?}'\nResponse: '{}'",
status_code,
reason
)]
RequestExecutionFailed {
status_code: Option<u16>,
reason: String,
},
#[error("Api root link header not found in header_map: {:?}", header_map)]
ApiRootLinkHeaderNotFound { header_map: Arc<WpNetworkHeaderMap> },
#[error(
"Api root link header not found!\nStatus Code: '{:#?}'\nHeader Map: '{:#?}'",
status_code,
header_map
)]
ApiRootLinkHeaderNotFound {
header_map: Arc<WpNetworkHeaderMap>,
status_code: u16,
},
}

impl From<RequestExecutionError> for FetchApiRootUrlError {
Expand Down

0 comments on commit 1680f77

Please sign in to comment.