Skip to content

Commit 7ae8b96

Browse files
committed
HTML error page
1 parent c88d6de commit 7ae8b96

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

elm.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@
99
"NoRedInk/elm-json-decode-pipeline": "1.0.1",
1010
"elm/core": "1.0.5",
1111
"elm/json": "1.1.3",
12-
"elm/url": "1.0.0"
12+
"elm/url": "1.0.0",
13+
"zwilias/elm-html-string": "2.0.2"
1314
},
14-
"indirect": {}
15+
"indirect": {
16+
"NoRedInk/elm-string-conversions": "1.0.1",
17+
"elm/bytes": "1.0.8",
18+
"elm/file": "1.0.5",
19+
"elm/html": "1.0.0",
20+
"elm/http": "2.0.0",
21+
"elm/time": "1.0.0",
22+
"elm/virtual-dom": "1.0.3"
23+
}
1524
},
1625
"test-dependencies": {
1726
"direct": {},
18-
"indirect": {
19-
"elm/time": "1.0.0"
20-
}
27+
"indirect": {}
2128
}
2229
}

src/Main.elm

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
port module Main exposing (main)
22

33
import Dict
4+
import Html.String as Html
5+
import Html.String.Attributes as Html
46
import Json.Decode as Decode exposing (Decoder, Error)
57
import Json.Decode.Pipeline as Decode
68
import Json.Encode as Encode
@@ -137,6 +139,28 @@ main =
137139
}
138140

139141

142+
errorMessage : String -> String
143+
errorMessage msg =
144+
Html.div
145+
[ Html.style "display" "flex"
146+
, Html.style "justify-content" "center"
147+
, Html.style "flex-direction" "column"
148+
, Html.style "align-items" "center"
149+
]
150+
[ Html.div [] [ Html.h1 [] [ Html.text "Cockpit CMS proxy" ] ]
151+
, Html.div [] [ Html.text "There seems to be an error in the proxy configuration" ]
152+
, Html.div [ Html.style "margin-top" "20px" ]
153+
[ Html.code
154+
[ Html.style "background-color" "#f1f1f1"
155+
, Html.style "color" "crimson"
156+
, Html.style "padding" "10px"
157+
]
158+
[ Html.text msg ]
159+
]
160+
]
161+
|> Html.toString 2
162+
163+
140164
update : Msg -> Config -> ( Config, Cmd Msg )
141165
update msg config =
142166
case msg of
@@ -147,7 +171,7 @@ update msg config =
147171
( config
148172
, { response = response
149173
, request = request
150-
, meta = MetaOutputError { success = False, data = err }
174+
, meta = MetaOutputError { success = False, data = errorMessage err }
151175
}
152176
|> toOutput
153177
)

0 commit comments

Comments
 (0)