summaryrefslogtreecommitdiffhomepage
path: root/mullvad-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-api/src')
-rw-r--r--mullvad-api/src/rest.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs
index 9211450cbb..39ed98d370 100644
--- a/mullvad-api/src/rest.rs
+++ b/mullvad-api/src/rest.rs
@@ -729,20 +729,16 @@ fn flatten_result<T, E>(
}
}
-impl From<hyper::Error> for Error {
- fn from(value: hyper::Error) -> Self {
- Error::HyperError(Arc::new(value))
- }
-}
-
-impl From<serde_json::Error> for Error {
- fn from(value: serde_json::Error) -> Self {
- Error::DeserializeError(Arc::new(value))
- }
+macro_rules! impl_into_arc_err {
+ ($ty:ty) => {
+ impl From<$ty> for Error {
+ fn from(error: $ty) -> Self {
+ Error::from(Arc::from(error))
+ }
+ }
+ };
}
-impl From<http::Error> for Error {
- fn from(value: http::Error) -> Self {
- Error::HttpError(Arc::new(value))
- }
-}
+impl_into_arc_err!(hyper::Error);
+impl_into_arc_err!(serde_json::Error);
+impl_into_arc_err!(http::Error);