diff --git a/Cargo.lock b/Cargo.lock
index 7cd75c2..e95d879 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -410,12 +410,6 @@ dependencies = [
"unicode-xid",
]
-[[package]]
-name = "convert_case"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
-
[[package]]
name = "convert_case"
version = "0.6.0"
@@ -464,19 +458,6 @@ dependencies = [
"syn 2.0.28",
]
-[[package]]
-name = "derive_more"
-version = "0.99.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
-dependencies = [
- "convert_case 0.4.0",
- "proc-macro2",
- "quote",
- "rustc_version",
- "syn 1.0.109",
-]
-
[[package]]
name = "digest"
version = "0.10.7"
@@ -504,7 +485,7 @@ name = "dyesub"
version = "0.1.0"
dependencies = [
"askama",
- "derive_more",
+ "err-derive",
"kle-serial",
"lazy_static",
"serde_json",
@@ -526,7 +507,6 @@ name = "dyesub-tool"
version = "0.1.0"
dependencies = [
"class_list",
- "derive_more",
"kle-serial",
"lazy_static",
"leptos",
@@ -534,6 +514,7 @@ dependencies = [
"strum",
"strum_macros",
"svg-units",
+ "thiserror",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -1111,7 +1092,7 @@ checksum = "0bdd7a21d20ca21bb12d67d050d4b0ad9973b156bce98f499f8b1789f11959dd"
dependencies = [
"attribute-derive",
"cfg-if",
- "convert_case 0.6.0",
+ "convert_case",
"html-escape",
"itertools",
"leptos_hot_reload",
@@ -1712,15 +1693,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-[[package]]
-name = "rustc_version"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
-dependencies = [
- "semver",
-]
-
[[package]]
name = "rustix"
version = "0.38.8"
@@ -1767,12 +1739,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c309e515543e67811222dbc9e3dd7e1056279b782e1dacffe4242b718734fb6"
-[[package]]
-name = "semver"
-version = "1.0.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
-
[[package]]
name = "serde"
version = "1.0.183"
@@ -1978,11 +1944,11 @@ dependencies = [
name = "svg-units"
version = "0.1.0"
dependencies = [
- "err-derive",
"lazy_static",
"regex",
"strum",
"strum_macros",
+ "thiserror",
]
[[package]]
diff --git a/dyesub-tool/Cargo.toml b/dyesub-tool/Cargo.toml
index 0002f49..a913e7d 100644
--- a/dyesub-tool/Cargo.toml
+++ b/dyesub-tool/Cargo.toml
@@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
svg-units = { path = "../svg-units" }
class_list = "0.1.1"
-derive_more = "0.99.17"
kle-serial = "0.2.2"
lazy_static = "1.4.0"
leptos = { version = "0.4.8", features = ["csr", "nightly"] }
@@ -15,6 +14,7 @@ strum = "0.25.0"
strum_macros = "0.25.2"
wasm-bindgen = "0.2.87"
wasm-bindgen-futures = "0.4.37"
+thiserror = "1.0.47"
[dependencies.web-sys]
version = "0.3.64"
diff --git a/dyesub-tool/src/components/keyboardfromfile.rs b/dyesub-tool/src/components/keyboardfromfile.rs
index 9a5ff38..ddb507c 100644
--- a/dyesub-tool/src/components/keyboardfromfile.rs
+++ b/dyesub-tool/src/components/keyboardfromfile.rs
@@ -1,3 +1,5 @@
+use std::error::Error;
+
use leptos::{html::Input, *};
use web_sys::File;
@@ -20,24 +22,15 @@ pub fn KeyboardFromFile(
Ok(keyboard) => {
set_result_message(Some(ResultMessageData {
title: "Success".to_owned(),
- message: view! { cx,
- "Loaded KLE layout "{&keyboard.metadata.name}" successfully!"
- }
- .into_view(cx),
+ message: format!("Loaded KLE layout {} successfully!", &keyboard.metadata.name),
colorway: Colorway::Ok,
}));
set_keyboard(Some(keyboard));
}
Err(err) => {
- set_result_message(Some(ResultMessageData {
- message: view! { cx,
- {
- err.to_string()
- }
- }
- .into_view(cx),
- title: >::into(err).to_string(),
- colorway: Colorway::Bad,
+ set_result_message(Some({
+ let error: Box = Box::new(err);
+ error.into()
}));
file_input().unwrap().set_value("");
}
diff --git a/dyesub-tool/src/components/keyboardfromweb.rs b/dyesub-tool/src/components/keyboardfromweb.rs
index 0be3101..620a020 100644
--- a/dyesub-tool/src/components/keyboardfromweb.rs
+++ b/dyesub-tool/src/components/keyboardfromweb.rs
@@ -1,3 +1,5 @@
+use std::error::Error;
+
use leptos::{html::Input, *};
use web_sys::SubmitEvent;
@@ -24,24 +26,15 @@ pub fn KeyboardFromWeb(
Ok(keyboard) => {
set_result_message(Some(ResultMessageData {
title: "Success".to_owned(),
- message: view! { cx,
- "Loaded KLE layout "{&keyboard.metadata.name}" successfully!"
- }
- .into_view(cx),
+ message: format!("Loaded KLE layout {} successfully!", &keyboard.metadata.name),
colorway: Colorway::Ok,
}));
set_keyboard(Some(keyboard));
}
Err(err) => {
- set_result_message(Some(ResultMessageData {
- message: view! { cx,
- {
- err.to_string()
- }
- }
- .into_view(cx),
- title: >::into(err).to_string(),
- colorway: Colorway::Bad,
+ set_result_message(Some({
+ let error: Box = Box::new(err);
+ error.into()
}));
input_element().unwrap().set_value("");
}
diff --git a/dyesub-tool/src/components/resultmessage.rs b/dyesub-tool/src/components/resultmessage.rs
index 6e13e02..85460c3 100644
--- a/dyesub-tool/src/components/resultmessage.rs
+++ b/dyesub-tool/src/components/resultmessage.rs
@@ -1,15 +1,29 @@
use class_list::class_list;
use leptos::*;
+use std::error::Error;
use crate::models::Colorway;
#[derive(Clone)]
pub struct ResultMessageData {
pub title: String,
- pub message: View,
+ pub message: String,
pub colorway: Colorway,
}
+impl From> for ResultMessageData {
+ fn from(value: Box) -> Self {
+ Self {
+ title: value.to_string(),
+ message: value
+ .source()
+ .map(|source| source.to_string())
+ .unwrap_or_else(|| "".to_string()),
+ colorway: Colorway::Bad,
+ }
+ }
+}
+
#[component]
pub fn ResultMessage(cx: Scope, message: ReadSignal