diff --git a/docs/annotated_words.ods b/docs/annotated_words.ods index f5dc790..9d11e28 100644 Binary files a/docs/annotated_words.ods and b/docs/annotated_words.ods differ diff --git a/src/lib.rs b/src/lib.rs index 34726c6..e083cab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,9 +29,9 @@ pub const V0_MIN_NUMBER: u32 = 1; #[derive(Error, Debug, Eq, PartialEq)] pub enum Error { - #[error("Word does not exist")] + #[error("Word does not exist: {0}")] WordDoesNotExist(String), - #[error("Invalid version")] + #[error("Invalid version: {0}")] InvalidVersion(u8), #[error("Unimplemented version")] UnimplementedVersion(Version), diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 19ca4aa..2aa0a6c 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use std::fs::File; use csv::ReaderBuilder; diff --git a/this_algorithm-wasm/index.js b/this_algorithm-wasm/index.js index e4196a6..cfa49c0 100644 --- a/this_algorithm-wasm/index.js +++ b/this_algorithm-wasm/index.js @@ -7,6 +7,8 @@ import init, { address_from_lat_lon, address_to_lat_lon } from "./pkg/this_algor init().then(() => { let updateEncode = () => { if (!encodeAddressLat.value || !encodeAddressLon.value) { + encodeAddressResult.value = ""; + encodeAddressError.textContent = ""; return; } @@ -17,6 +19,7 @@ init().then(() => { encodeAddressResult.value = address_from_lat_lon(lat, lon); encodeAddressError.textContent = ""; } catch(e) { + encodeAddressResult.value = ""; encodeAddressError.textContent = e; } }; diff --git a/this_algorithm-wasm/src/lib.rs b/this_algorithm-wasm/src/lib.rs index 1f9a66f..682eca5 100644 --- a/this_algorithm-wasm/src/lib.rs +++ b/this_algorithm-wasm/src/lib.rs @@ -1,6 +1,5 @@ use std::str::FromStr; -use this_algorithm::Address; use wasm_bindgen::prelude::*; #[wasm_bindgen] @@ -12,16 +11,16 @@ extern "C" { #[wasm_bindgen] pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result { - Address::from_lat_lon(lat, lon) + this_algorithm::Address::from_lat_lon(lat, lon) .map(|a| a.to_string()) .map_err(|e| e.to_string()) } #[wasm_bindgen] pub fn address_to_lat_lon(addr_str: &str) -> Result, String> { - Address::from_str(addr_str) + this_algorithm::Address::from_str(addr_str) .as_ref() .map_err(|e| e.to_string()) - .map(Address::to_lat_lon) + .map(this_algorithm::Address::to_lat_lon) .map(|(lat, lon)| vec![lat, lon]) }