summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/error.rs (renamed from iced_builder/src/error.rs)27
1 files changed, 19 insertions, 8 deletions
diff --git a/iced_builder/src/error.rs b/src/error.rs
index 8876016..f4011bd 100644
--- a/iced_builder/src/error.rs
+++ b/src/error.rs
@@ -6,13 +6,18 @@ use thiserror::Error;
#[derive(Debug, Clone, Error)]
#[error(transparent)]
pub enum Error {
- IOError(Arc<io::Error>),
- SerdeError(Arc<serde_json::Error>),
- FormatError(Arc<rust_format::Error>),
- #[error("The element tree contains no matching element")]
+ 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"
+ "the file dialog has been closed without selecting a valid option"
)]
DialogClosed,
#[error("{0}")]
@@ -21,19 +26,19 @@ pub enum Error {
impl From<io::Error> for Error {
fn from(value: io::Error) -> Self {
- Self::IOError(Arc::new(value))
+ Self::IO(Arc::new(value))
}
}
impl From<serde_json::Error> for Error {
fn from(value: serde_json::Error) -> Self {
- Self::SerdeError(Arc::new(value))
+ Self::SerdeJSON(Arc::new(value))
}
}
impl From<rust_format::Error> for Error {
fn from(value: rust_format::Error) -> Self {
- Self::FormatError(Arc::new(value))
+ Self::RustFmt(Arc::new(value))
}
}
@@ -42,3 +47,9 @@ impl From<&str> for Error {
Self::Other(value.to_owned())
}
}
+
+impl From<String> for Error {
+ fn from(value: String) -> Self {
+ Self::Other(value)
+ }
+}