summaryrefslogtreecommitdiff
path: root/webhogg/wasm/src/error.rs
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-06-13 00:38:21 +0200
committernatrixaeria <janng@gmx.de>2019-06-13 00:38:21 +0200
commitc3fdf122bd874bd0aedf90eff0d57cc440fc6421 (patch)
tree0220c9961cd37a58d4398741aec32e6619379bbc /webhogg/wasm/src/error.rs
parent1b6a2835e57a7d399f43ecf493060e68042f9af8 (diff)
Split code into graphics and logic loop
Diffstat (limited to 'webhogg/wasm/src/error.rs')
-rw-r--r--webhogg/wasm/src/error.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/webhogg/wasm/src/error.rs b/webhogg/wasm/src/error.rs
new file mode 100644
index 0000000..b544112
--- /dev/null
+++ b/webhogg/wasm/src/error.rs
@@ -0,0 +1,30 @@
+use std::error::Error;
+
+#[derive(Debug)]
+pub enum WasmError {
+ TestError(String),
+}
+
+impl std::fmt::Display for WasmError {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+ write!(f, "{}: {}", self.name(), self.description())
+ }
+}
+
+impl Error for WasmError {
+ fn description(&self) -> &str {
+ match self {
+ WasmError::TestError(msg) => msg,
+ }
+ }
+
+ fn source(&self) -> Option<&'static dyn Error> { None }
+}
+
+impl WasmError {
+ pub fn name(&self) -> &str {
+ match self {
+ WasmError::TestError(_) => "TestError",
+ }
+ }
+}