retrom_plugin_installer/
error.rs1use std::num::ParseIntError;
2
3use reqwest::header::ToStrError;
4use serde::{ser::Serializer, Serialize};
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error(transparent)]
11 Io(#[from] std::io::Error),
12 #[error(transparent)]
13 Tauri(#[from] tauri::Error),
14 #[error(transparent)]
15 Reqwest(#[from] reqwest::Error),
16 #[error(transparent)]
17 ToStr(#[from] ToStrError),
18 #[error(transparent)]
19 ParseInt(#[from] ParseIntError),
20 #[error("Tonic Error: {0}")]
21 Tonic(tonic::Code),
22 #[error("No third party data found")]
23 ThirdPartyNotFound,
24 #[error(transparent)]
25 SteamError(#[from] retrom_plugin_steam::Error),
26 #[error(transparent)]
27 OpenPathError(#[from] tauri_plugin_opener::Error),
28 #[error(transparent)]
29 ConfigError(#[from] retrom_plugin_config::Error),
30 #[error("Cannot migrate installation directory: {0}")]
31 MigrationError(String),
32 #[error("Internal Error: {0}")]
33 InternalError(String),
34 #[error(transparent)]
35 DecodeError(#[from] prost::DecodeError),
36 #[error("Installation Failed: {0}")]
37 InstallationFailed(String),
38 #[error("Installation Aborted")]
39 InstallationAborted,
40 #[error("Already Installing")]
41 AlreadyInstalling,
42 #[error("Already Installed")]
43 AlreadyInstalled,
44 #[error("Not Installing")]
45 NotInstalling,
46}
47
48impl From<tonic::Status> for Error {
49 fn from(status: tonic::Status) -> Self {
50 Error::Tonic(status.code())
51 }
52}
53
54impl Serialize for Error {
55 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
56 where
57 S: Serializer,
58 {
59 serializer.serialize_str(self.to_string().as_ref())
60 }
61}