// Workspace: weaponry // File: weaponry/src/error.rs //! Inner weaponry error definition #![allow(missing_docs, clippy::missing_docs_in_private_items)] use thiserror::Error; #[derive(Error, Debug)] /// Unrecoverable Error, all these error cannot gracefully fail and must return to the User for further handling pub enum FatalEquipementError { #[error("Rusqlite failed to connect to the given path {0}")] RusqliteConnection(#[from] rusqlite::Error), #[error("Deserialization from object failed : rowid {row_id} \n{error}")] SerdeRusqlite { error: serde_rusqlite::Error, row_id: usize, }, #[error("Deserialisation from json failed : {0}")] SerdeJSON(#[from] serde_json::Error), #[error( "Deserialisation from json failed at line {line} on file {file} while trying to parse the value: {parsed_value}: {error}]" )] SerdeJSONAt { line: String, file: String, error: serde_json::Error, parsed_value: String, }, #[error("Couldn't convert into type {origin_type} with data {data}")] Conversion { origin_type: String, data: String }, } #[derive(Error, Debug)] /// Recoverable error, all these error exist to signal a retry or another path that should be taken by the program pub enum LocalEquipementError { #[error("Very simple error")] Oops, } #[derive(Error, Debug)] /// An equipement error, either unrecoverable, indicating a that the execution /// flow must be stopped and only an user input can solve the issue pub enum EquipementError { #[error("An unrecoverable error occured: {0}")] Fatal(#[from] FatalEquipementError), #[error("A local error occured an wasn't recovered from: {0}")] Local(#[from] LocalEquipementError), }