From 89404ccb35414f3b39c277f8219d1aa5878fd73c Mon Sep 17 00:00:00 2001 From: pml68 Date: Mon, 4 Nov 2024 01:26:05 +0100 Subject: feat(error): use `Arc` instead of .to_string for From impls --- iced_builder/src/error.rs | 19 ++++++++++--------- 1 file 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), + #[error(transparent)] + SerdeError(Arc), + #[error(transparent)] + FormatError(Arc), #[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 for Error { fn from(value: io::Error) -> Self { - Self::IOError(value.to_string()) + Self::IOError(Arc::new(value)) } } impl From for Error { fn from(value: serde_json::Error) -> Self { - Self::SerdeError(value.to_string()) + Self::SerdeError(Arc::new(value)) } } impl From for Error { fn from(value: rust_format::Error) -> Self { - Self::FormatError(value.to_string()) + Self::FormatError(Arc::new(value)) } } -- cgit v1.2.3