deduplicated RemoteError

This commit is contained in:
2026-01-25 21:54:36 +08:00
parent a48e34adc7
commit d1ef0a010f
6 changed files with 14 additions and 20 deletions

View File

@@ -1,15 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error;
use ts_rs::TS; use ts_rs::TS;
#[derive(Error, Debug)]
pub enum RemoteError {
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("JSON parse error: {0}")]
Json(#[from] serde_json::Error),
}
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)] #[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]

View File

@@ -1,19 +1,8 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error;
use ts_rs::TS; use ts_rs::TS;
use super::dolls::DollDto; use super::dolls::DollDto;
#[derive(Error, Debug)]
pub enum RemoteError {
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("JSON parse error: {0}")]
Json(#[from] serde_json::Error),
#[error("{0}")]
Api(String),
}
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)] #[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]

View File

@@ -1,4 +1,5 @@
pub mod app_data; pub mod app_data;
pub mod remote_error;
pub mod dolls; pub mod dolls;
pub mod friends; pub mod friends;
pub mod health; pub mod health;

View File

@@ -0,0 +1,11 @@
use thiserror::Error;
#[derive(Error, Debug)]
pub enum RemoteError {
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("JSON parse error: {0}")]
Json(#[from] serde_json::Error),
#[error("{0}")]
Api(String),
}

View File

@@ -1,6 +1,7 @@
use reqwest::Client; use reqwest::Client;
use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::dolls::*}; use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::dolls::*};
use crate::models::remote_error::RemoteError;
pub struct DollsRemote { pub struct DollsRemote {
pub base_url: String, pub base_url: String,

View File

@@ -1,6 +1,7 @@
use reqwest::Client; use reqwest::Client;
use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::friends::*}; use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::friends::*};
use crate::models::remote_error::RemoteError;
pub struct FriendRemote { pub struct FriendRemote {
pub base_url: String, pub base_url: String,