1use thiserror::Error as ErrorBase;
2
3use std::time::SystemTimeError;
4use serde_json::error::Error as SerdeJsonError;
5use reqwest::Error as ReqwestError;
6use std::num::{
7 ParseFloatError,
8 ParseIntError,
9};
10
11
12#[derive(Debug, ErrorBase)]
14#[allow(clippy::module_name_repetitions)]
15pub enum UpdateInfoError {
16 #[error("Failed to parse data: {0}")]
18 ParseFloatError(#[from] ParseFloatError),
19
20 #[error("Faield to parse data: {0}")]
22 ParseIntError(#[from] ParseIntError),
23
24 #[error("Missing an expected json field")]
26 MissingData,
27}
28
29
30#[derive(Debug, ErrorBase)]
32pub enum Error {
33 #[error("Failed to get current time: {0}")]
35 TimeError(#[from] SystemTimeError),
36
37 #[error("RequestError: {0}")]
39 RequestError(#[from] ReqwestError),
40
41 #[error("Failed to parse JSON: {0}")]
43 JsonParseError(#[from] SerdeJsonError),
44
45 #[error("Failed to update data fields: {0}")]
47 UpdateInfoError(#[from] UpdateInfoError),
48
49 #[error("Failed to find the required information needed to start the game")]
51 NoDataFound,
52
53 #[error("The akinator servers in that region are currently down")]
55 ServersDown,
56
57 #[error("There is a technical error with the akinator servers")]
59 TechnicalError,
60
61 #[error("Akinator session timed out waiting for a response")]
63 TimeoutError,
64
65 #[error("There are no more available questions")]
67 NoMoreQuestions,
68
69 #[error("Failed to connect to akinator servers")]
71 ConnectionError,
72
73 #[error("Cannot go back any further, you are already on the first question")]
75 CantGoBackAnyFurther,
76
77 #[error("Invalid Answer")]
79 InvalidAnswer,
80
81 #[error("Invalid Language")]
83 InvalidLanguage,
84}
85
86pub type Result<T, E = Error> = std::result::Result<T, E>;