1use thiserror::Error;
6
7#[derive(Error, Debug)]
9pub enum HopeError {
10 #[error("Modul hiba: {0}")]
11 Module(String),
12
13 #[error("Regisztráció hiba: {0}")]
14 Registration(String),
15
16 #[error("Nem található: {0}")]
17 NotFound(String),
18
19 #[error("Graf hiba: {0}")]
20 Graph(String),
21
22 #[error("gRPC hiba: {0}")]
23 Grpc(#[from] tonic::Status),
24
25 #[error("gRPC transport hiba: {0}")]
26 Transport(#[from] tonic::transport::Error),
27
28 #[error("IO hiba: {0}")]
29 Io(#[from] std::io::Error),
30
31 #[error("JSON hiba: {0}")]
32 Json(#[from] serde_json::Error),
33
34 #[error("HTTP hiba: {0}")]
35 Http(#[from] reqwest::Error),
36
37 #[error("Voice hiba: {0}")]
38 Voice(String),
39
40 #[error("Általános hiba: {0}")]
41 General(String),
42}
43
44impl From<String> for HopeError {
46 fn from(s: String) -> Self {
47 HopeError::General(s)
48 }
49}
50
51impl From<&str> for HopeError {
52 fn from(s: &str) -> Self {
53 HopeError::General(s.to_string())
54 }
55}
56
57pub type HopeResult<T> = Result<T, HopeError>;