diff options
| author | Polesznyák Márk László <116908301+pml68@users.noreply.github.com> | 2025-01-11 23:13:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-11 23:13:07 +0100 |
| commit | 103699beeb8bdce38bc5803cbe038e74cbc20e40 (patch) | |
| tree | b79e13b3decc778cc7c66af7187c647ae0a21a52 /src/error.rs | |
| parent | Merge pull request #4 from pml68/feat/playground (diff) | |
| parent | refactor: remove iced_drop & workspace (diff) | |
| download | iced-builder-103699beeb8bdce38bc5803cbe038e74cbc20e40.tar.gz | |
Merge pull request #5 from pml68/feat/config
Config done
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..f4011bd --- /dev/null +++ b/src/error.rs @@ -0,0 +1,55 @@ +use std::io; +use std::sync::Arc; + +use thiserror::Error; + +#[derive(Debug, Clone, Error)] +#[error(transparent)] +pub enum Error { + IO(Arc<io::Error>), + #[error("config does not exist")] + ConfigMissing, + #[error("JSON parsing error: {0}")] + SerdeJSON(Arc<serde_json::Error>), + #[error("TOML parsing error: {0}")] + SerdeTOML(#[from] toml::de::Error), + RustFmt(Arc<rust_format::Error>), + #[error("the element tree contains no matching element")] + NonExistentElement, + #[error( + "the file dialog has been closed without selecting a valid option" + )] + DialogClosed, + #[error("{0}")] + Other(String), +} + +impl From<io::Error> for Error { + fn from(value: io::Error) -> Self { + Self::IO(Arc::new(value)) + } +} + +impl From<serde_json::Error> for Error { + fn from(value: serde_json::Error) -> Self { + Self::SerdeJSON(Arc::new(value)) + } +} + +impl From<rust_format::Error> for Error { + fn from(value: rust_format::Error) -> Self { + Self::RustFmt(Arc::new(value)) + } +} + +impl From<&str> for Error { + fn from(value: &str) -> Self { + Self::Other(value.to_owned()) + } +} + +impl From<String> for Error { + fn from(value: String) -> Self { + Self::Other(value) + } +} |
