Skip to content

Commit 3f6afa6

Browse files
committed
for MPP-4235: change Relay's ApiError to RelayApiError
1 parent 63da186 commit 3f6afa6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

components/relay/src/error.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ pub use error_support::error;
66
use error_support::{ErrorHandling, GetErrorHandling};
77

88
pub type Result<T> = std::result::Result<T, Error>;
9-
pub type ApiResult<T> = std::result::Result<T, ApiError>;
9+
pub type ApiResult<T> = std::result::Result<T, RelayApiError>;
1010

1111
#[derive(Debug, thiserror::Error, uniffi::Error)]
12-
pub enum ApiError {
12+
pub enum RelayApiError {
1313
#[error("Relay network error: {reason}")]
1414
Network { reason: String },
1515

@@ -34,21 +34,21 @@ pub enum Error {
3434
}
3535

3636
impl GetErrorHandling for Error {
37-
type ExternalError = ApiError;
37+
type ExternalError = RelayApiError;
3838

3939
fn get_error_handling(&self) -> ErrorHandling<Self::ExternalError> {
4040
match self {
4141
Error::Viaduct(viaduct::Error::NetworkError(e)) => {
42-
ErrorHandling::convert(ApiError::Network {
42+
ErrorHandling::convert(RelayApiError::Network {
4343
reason: e.to_string(),
4444
})
4545
.log_warning()
4646
}
47-
Error::RelayApi(detail) => ErrorHandling::convert(ApiError::RelayApi {
47+
Error::RelayApi(detail) => ErrorHandling::convert(RelayApiError::RelayApi {
4848
detail: detail.clone(),
4949
})
5050
.report_error("relay-api-error"),
51-
_ => ErrorHandling::convert(ApiError::Other {
51+
_ => ErrorHandling::convert(RelayApiError::Other {
5252
reason: self.to_string(),
5353
})
5454
.report_error("relay-unexpected-error"),

components/relay/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod error;
66

77
uniffi::setup_scaffolding!("relay");
88

9-
pub use error::{ApiError, ApiResult, Error, Result};
9+
pub use error::{ApiResult, Error, RelayApiError, Result};
1010
use error_support::handle_error;
1111

1212
use serde::{Deserialize, Serialize};
@@ -50,7 +50,7 @@ struct CreateAddressPayload<'a> {
5050
}
5151

5252
#[derive(Deserialize)]
53-
struct ApiErrorMessage {
53+
struct RelayApiErrorMessage {
5454
detail: String,
5555
}
5656

@@ -88,7 +88,7 @@ impl RelayClient {
8888
let response = request.send()?;
8989
let body = response.text();
9090
log::trace!("response text: {}", body);
91-
if let Ok(parsed) = serde_json::from_str::<ApiErrorMessage>(&body) {
91+
if let Ok(parsed) = serde_json::from_str::<RelayApiErrorMessage>(&body) {
9292
return Err(Error::RelayApi(parsed.detail));
9393
}
9494

@@ -104,7 +104,7 @@ impl RelayClient {
104104
let response = request.send()?;
105105
let body = response.text();
106106
log::trace!("response text: {}", body);
107-
if let Ok(parsed) = serde_json::from_str::<ApiErrorMessage>(&body) {
107+
if let Ok(parsed) = serde_json::from_str::<RelayApiErrorMessage>(&body) {
108108
return Err(Error::RelayApi(parsed.detail));
109109
}
110110
Ok(())
@@ -132,7 +132,7 @@ impl RelayClient {
132132
let response = request.send()?;
133133
let body = response.text();
134134
log::trace!("response text: {}", body);
135-
if let Ok(parsed) = serde_json::from_str::<ApiErrorMessage>(&body) {
135+
if let Ok(parsed) = serde_json::from_str::<RelayApiErrorMessage>(&body) {
136136
return Err(Error::RelayApi(parsed.detail));
137137
}
138138

0 commit comments

Comments
 (0)