summaryrefslogtreecommitdiff
path: root/iced_builder/src/lib.rs
diff options
context:
space:
mode:
authorPolesznyák Márk László <116908301+pml68@users.noreply.github.com>2024-10-26 22:23:44 +0200
committerGitHub <noreply@github.com>2024-10-26 22:23:44 +0200
commit95fcd7aefa1aaf8f69c719d6d66003311c097e97 (patch)
treeda813fb6d9bab57d9b114280f761a9635a1a8903 /iced_builder/src/lib.rs
parentMerge pull request #2 from pml68/feat/drag-and-drop (diff)
parentfeat: implement `std::error::Error` for custom `Error` enum (diff)
downloadiced-builder-95fcd7aefa1aaf8f69c719d6d66003311c097e97.tar.gz
Merge pull request #3 from pml68/refactor/internal-restructuring
Internal restructuring done
Diffstat (limited to 'iced_builder/src/lib.rs')
-rw-r--r--iced_builder/src/lib.rs38
1 files changed, 13 insertions, 25 deletions
diff --git a/iced_builder/src/lib.rs b/iced_builder/src/lib.rs
index 420b14c..14a044e 100644
--- a/iced_builder/src/lib.rs
+++ b/iced_builder/src/lib.rs
@@ -1,4 +1,5 @@
pub mod types;
+pub mod views;
use std::path::PathBuf;
@@ -7,41 +8,27 @@ use types::{
element_name::ElementName, project::Project, rendered_element::RenderedElement, DesignerPage,
};
-#[derive(Debug, Clone)]
+use thiserror::Error;
+
+#[derive(Debug, Clone, Error)]
pub enum Error {
- IOError(std::io::ErrorKind),
+ #[error("an IO error accured: {0}")]
+ IOError(String),
+ #[error("a Serde error accured: {0}")]
SerdeError(String),
+ #[error("an RustFmt error accured: {0}")]
FormatError(String),
+ #[error("the element tree contains no matching element")]
NonExistentElement,
+ #[error("the file dialog has been closed without selecting a valid option")]
DialogClosed,
+ #[error("{0}")]
String(String),
}
-impl std::fmt::Display for Error {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- Self::SerdeError(string) | Self::FormatError(string) | Self::String(string) => {
- write!(f, "{}", string)
- }
- Self::IOError(kind) => {
- write!(f, "{}", kind)
- }
- Self::NonExistentElement => {
- write!(f, "The element tree contains no matching element.")
- }
- Self::DialogClosed => {
- write!(
- f,
- "The file dialog has been closed without selecting a valid option."
- )
- }
- }
- }
-}
-
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
- Self::IOError(value.kind())
+ Self::IOError(value.to_string())
}
}
@@ -87,5 +74,6 @@ pub enum Message {
OpenFile,
FileOpened(Result<(PathBuf, Project), Error>),
SaveFile,
+ SaveFileAs,
FileSaved(Result<PathBuf, Error>),
}