on master help sign in
Put in some temporary logic for decoding errors
commitd428362c138accaeccfda5494d7ca355b9b80700 authorEvan Czaplicki <evancz@users.noreply.github.com> dateSat 7 Apr 2018, 19:56 (9 years ago) parentb1fd35f
1 file changed+52−25
ui/browser/src/Errors.elm+52−25
ui/browser/src/Errors.elm+52−25
@@ -6,16 +6,18 @@ import Char
66import Html exposing (..)
77import Html.Attributes exposing (..)
88import String
9+import Json.Decode as D
910
1011
1112
1213-- MAIN
1314
1415
16+main : Program D.Value Model ()
1517main =
1618 Browser.fullscreen
17− { init = \env -> (env.flags, Cmd.none)
18− , update = \_ model -> (model, Cmd.none)
19+ { init = \env -> (D.decodeValue decodeExit env.flags, Cmd.none)
20+ , update = \_ exit -> (exit, Cmd.none)
1921 , view = view
2022 , subscriptions = \_ -> Sub.none
2123 , onNavigation = Nothing
@@ -23,31 +25,56 @@ main =
2325
2426
2527
28+-- MODEL
29+
30+
31+type alias Model =
32+ Result D.Error Exit
33+
34+
35+type alias Exit = ()
36+
37+
38+decodeExit : D.Decoder Exit
39+decodeExit =
40+ D.null ()
41+
42+
43+
2644-- VIEW
2745
2846
29−view : String -> Browser.View msg
30−view message =
31− { title = "Error"
47+view : Model -> Browser.View msg
48+view result =
49+ { title = "Problem!"
3250 , body =
33− [ div
34− [ style "width" "100%"
35− , style "min-height" "100%"
36− , style "display" "flex"
37− , style "flex-direction" "column"
38− , style "align-items" "center"
39− , style "background-color" "black"
40− , style "color" "rgb(233, 235, 235)"
41− , style "font-family" "monospace"
42− ]
43− [ div
44− [ style "display" "block"
45− , style "white-space" "pre"
46− , style "background-color" "rgb(39, 40, 34)"
47− , style "padding" "2em"
48− ]
49− [ text message
50− ]
51− ]
52− ]
51+ case result of
52+ Err err ->
53+ [ text (D.errorToString err) ]
54+
55+ Ok exit ->
56+ [ viewExit exit ]
5357 }
58+
59+
60+viewExit : Exit -> Html msg
61+viewExit exit =
62+ div
63+ [ style "width" "100%"
64+ , style "min-height" "100%"
65+ , style "display" "flex"
66+ , style "flex-direction" "column"
67+ , style "align-items" "center"
68+ , style "background-color" "black"
69+ , style "color" "rgb(233, 235, 235)"
70+ , style "font-family" "monospace"
71+ ]
72+ [ div
73+ [ style "display" "block"
74+ , style "white-space" "pre"
75+ , style "background-color" "rgb(39, 40, 34)"
76+ , style "padding" "2em"
77+ ]
78+ [ text "TODO"
79+ ]
80+ ]