on master help sign in
Put in some temporary logic for decoding errors
d428362Evan Czaplicki
ui/browser/src/Errors.elm+52−25
@@ -6,16 +6,18 @@ import Char
6import Html exposing (..)
6import Html exposing (..)
7import Html.Attributes exposing (..)
7import Html.Attributes exposing (..)
8import String
8import String
9+import Json.Decode as D
9
10
10
11
11
12
12-- MAIN
13-- MAIN
13
14
14
15
16+main : Program D.Value Model ()
15main =
17main =
16 Browser.fullscreen
18 Browser.fullscreen
17− { init = \env -> (env.flags, Cmd.none)
19+ { init = \env -> (D.decodeValue decodeExit env.flags, Cmd.none)
18− , update = \_ model -> (model, Cmd.none)
20+ , update = \_ exit -> (exit, Cmd.none)
19 , view = view
21 , view = view
20 , subscriptions = \_ -> Sub.none
22 , subscriptions = \_ -> Sub.none
21 , onNavigation = Nothing
23 , onNavigation = Nothing
@@ -23,31 +25,56 @@ main =
23
25
24
26
25
27
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+
26-- VIEW
44-- VIEW
27
45
28
46
29−view : String -> Browser.View msg
47+view : Model -> Browser.View msg
30−view message =
48+view result =
31− { title = "Error"
49+ { title = "Problem!"
32 , body =
50 , body =
33− [ div
51+ case result of
34− [ style "width" "100%"
52+ Err err ->
35− , style "min-height" "100%"
53+ [ text (D.errorToString err) ]
36− , style "display" "flex"
54+
37− , style "flex-direction" "column"
55+ Ok exit ->
38− , style "align-items" "center"
56+ [ viewExit exit ]
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− ]
53 }
57 }
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+ ]