1use polyoxide_core::{ApiError, RequestError};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
6pub enum DataApiError {
7 #[error(transparent)]
9 Api(#[from] ApiError),
10}
11
12impl RequestError for DataApiError {
13 async fn from_response(response: reqwest::Response) -> Self {
14 Self::Api(ApiError::from_response(response).await)
15 }
16}
17
18polyoxide_core::impl_api_error_conversions!(DataApiError);
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn data_api_error_from_api_error() {
27 let api_err = ApiError::Api {
28 status: 404,
29 message: "not found".to_string(),
30 };
31 let data_err = DataApiError::from(api_err);
32 let msg = format!("{}", data_err);
33 assert!(
34 msg.contains("not found"),
35 "DataApiError should forward ApiError message: {}",
36 msg
37 );
38 }
39
40 #[test]
41 fn data_api_error_is_send_sync() {
42 fn assert_send_sync<T: Send + Sync>() {}
43 assert_send_sync::<DataApiError>();
46 }
47}