Skip to content

Commit

Permalink
Improve error message presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Aug 17, 2022
1 parent 88291af commit 8b63c3d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ init _ =

dataUrl : String
dataUrl =
"https://opendata.ecdc.europa.eu/monkeypox/casedistribution/json/data.json"
"https://opendata.ecdc.europa.eu/monkeypox/casedistribution/json/data.jsons"


update : Msg -> Model -> ( Model, Cmd Msg )
Expand Down Expand Up @@ -232,8 +232,19 @@ view model =
]

RemoteData.Failure error ->
[ div [ class "alert alert-info" ]
[ text <| errorToString error ]
[ div [ class "alert alert-warning p-4" ]
[ p [ class "fw-bold" ]
[ text "Unable to retrieve "
, a [ href dataUrl, target "_blank" ]
[ text "dataset" ]
, text ":"
]
, pre [] [ text <| errorToString error ]
, div []
[ a [ href "https://github.com/n1k0/monkeypox-stats/issues/new" ]
[ text "Report an issue" ]
]
]
]

RemoteData.Success events ->
Expand Down Expand Up @@ -268,8 +279,8 @@ errorToString error =
Http.BadStatus 400 ->
"Verify your information and try again"

Http.BadStatus _ ->
"Unknown error"
Http.BadStatus status ->
"HTTP error " ++ String.fromInt status

Http.BadBody errorMessage ->
errorMessage
Expand Down

0 comments on commit 8b63c3d

Please sign in to comment.