Skip to main content

retrom_plugin_launcher/
error.rs

1use serde::{ser::Serializer, Serialize};
2use tokio::sync::mpsc::error::SendError;
3
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    #[error(transparent)]
9    Io(#[from] std::io::Error),
10    #[error(transparent)]
11    Tauri(#[from] tauri::Error),
12    #[error(transparent)]
13    Send(#[from] SendError<()>),
14    #[error("Cannot launch unininstalled game with id `{0}`")]
15    NotInstalled(i32),
16    #[error("Cannot find appropriate file for game with id `{0}`")]
17    FileNotFound(i32),
18    #[error("Cannot find game with id `{0:?}`")]
19    GameNotFound(Option<i32>),
20    #[error(transparent)]
21    Steam(#[from] retrom_plugin_steam::Error),
22    #[error(transparent)]
23    DecodeError(#[from] prost::DecodeError),
24
25    #[error("InternalError: {0}")]
26    InternalError(String),
27}
28
29impl Serialize for Error {
30    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
31    where
32        S: Serializer,
33    {
34        serializer.serialize_str(self.to_string().as_ref())
35    }
36}