1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Macros for reducing boilerplate in API client implementations
/// Implements standard error conversions for API error wrapper types
///
/// This macro generates `From` implementations for `reqwest::Error` and `url::ParseError`
/// that wrap them in the `Api` variant of the error type.
///
/// # Example
///
/// ```ignore
/// use polyoxide_core::{ApiError, RequestError};
/// use thiserror::Error;
///
/// #[derive(Error, Debug)]
/// pub enum MyApiError {
/// #[error(transparent)]
/// Api(#[from] ApiError),
/// }
///
/// impl RequestError for MyApiError {
/// async fn from_response(response: reqwest::Response) -> Self {
/// Self::Api(ApiError::from_response(response).await)
/// }
/// }
///
/// // Instead of writing these manually:
/// // impl From<reqwest::Error> for MyApiError { ... }
/// // impl From<url::ParseError> for MyApiError { ... }
///
/// // Use the macro:
/// polyoxide_core::impl_api_error_conversions!(MyApiError);
/// ```