summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-09-13 16:51:08 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-09-13 16:51:08 +0200
commit9ec5806bc721734923ff4c93f7ef1f97a6a03248 (patch)
treec80b737a8bf0cc6e311c4fe7256f68e7ea8e158a /src/Struct/Error.elm
Starting an browser extension for TO...
Diffstat (limited to 'src/Struct/Error.elm')
-rw-r--r--src/Struct/Error.elm45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Struct/Error.elm b/src/Struct/Error.elm
new file mode 100644
index 0000000..5f40c09
--- /dev/null
+++ b/src/Struct/Error.elm
@@ -0,0 +1,45 @@
+module Struct.Error exposing (Type, Mode(..), new, to_string)
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Mode =
+ IllegalAction
+ | Programming
+ | Unimplemented
+ | Networking
+ | Failure
+
+type alias Type =
+ {
+ mode: Mode,
+ message: String
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Mode -> String -> Type
+new mode str =
+ {
+ mode = mode,
+ message = str
+ }
+
+to_string : Type -> String
+to_string e =
+ (
+ (case e.mode of
+ Failure -> "The action failed: "
+ IllegalAction -> "Request discarded: "
+ Programming -> "Error in the program (please report): "
+ Unimplemented -> "Update discarded due to unimplemented feature: "
+ Networking -> "Error while conversing with the server: "
+ )
+ ++ e.message
+ )
+