summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ElmModule/Update.elm')
-rw-r--r--src/ElmModule/Update.elm35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/ElmModule/Update.elm b/src/ElmModule/Update.elm
index 9fc9a93..7f02d79 100644
--- a/src/ElmModule/Update.elm
+++ b/src/ElmModule/Update.elm
@@ -1,6 +1,7 @@
module ElmModule.Update exposing (update)
-- Elm -------------------------------------------------------------------------
+import Http
-- Local Module ----------------------------------------------------------------
import Struct.Event
@@ -27,6 +28,15 @@ update event model =
((Update.Story.select_choice ix model), Cmd.none)
Struct.Event.None -> (model, Cmd.none)
+ (Struct.Event.UserInputInProgress string) ->
+ (
+ {model | ui = (Struct.UI.set_field_content string model.ui)},
+ Cmd.none
+ )
+
+ Struct.Event.UserInputValidated ->
+ ((Update.Story.handle_prompt_input model), Cmd.none)
+
(Struct.Event.LoadStory http_result) ->
case http_result of
(Ok story) ->
@@ -47,7 +57,30 @@ update event model =
{model |
ui =
(Struct.UI.display_string_error
- "Failed to load story"
+ (
+ "Failed to load story:\n"
+ ++
+ (
+ case error of
+ (Http.BadUrl details) ->
+ ("Bad URL: " ++ details)
+
+ Http.Timeout -> "Timeout."
+ Http.NetworkError -> "Network Error."
+ (Http.BadStatus code) ->
+ (
+ "Error code "
+ ++ (String.fromInt code)
+ ++ "."
+ )
+
+ (Http.BadBody details) ->
+ (
+ "Invalid content: "
+ ++ details
+ )
+ )
+ )
model.ui
)
},