diff options
| author | pml68 <contact@pml68.me> | 2024-11-04 01:26:05 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.me> | 2024-11-04 01:26:05 +0100 |
| commit | 89404ccb35414f3b39c277f8219d1aa5878fd73c (patch) | |
| tree | 2cbd7e979602c3017f37148fae3ab2c96b46b27f /iced_builder/src | |
| parent | feat: add error dialogs, windows manifest (diff) | |
| download | iced-builder-89404ccb35414f3b39c277f8219d1aa5878fd73c.tar.gz | |
feat(error): use `Arc` instead of .to_string for From impls
Diffstat (limited to '')
| -rw-r--r-- | iced_builder/src/error.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/iced_builder/src/error.rs b/iced_builder/src/error.rs index 5bf41b1..8987851 100644 --- a/iced_builder/src/error.rs +++ b/iced_builder/src/error.rs @@ -1,15 +1,16 @@ use rfd::{MessageButtons, MessageDialog, MessageLevel}; use std::io; +use std::sync::Arc; use thiserror::Error; #[derive(Debug, Clone, Error)] pub enum Error { - #[error("An I/O error accured: {0}")] - IOError(String), - #[error("A Serde error accured: {0}")] - SerdeError(String), - #[error("A RustFmt error accured: {0}")] - FormatError(String), + #[error(transparent)] + IOError(Arc<io::Error>), + #[error(transparent)] + SerdeError(Arc<serde_json::Error>), + #[error(transparent)] + FormatError(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")] @@ -20,19 +21,19 @@ pub enum Error { impl From<io::Error> for Error { fn from(value: io::Error) -> Self { - Self::IOError(value.to_string()) + Self::IOError(Arc::new(value)) } } impl From<serde_json::Error> for Error { fn from(value: serde_json::Error) -> Self { - Self::SerdeError(value.to_string()) + Self::SerdeError(Arc::new(value)) } } impl From<rust_format::Error> for Error { fn from(value: rust_format::Error) -> Self { - Self::FormatError(value.to_string()) + Self::FormatError(Arc::new(value)) } } |
