parent
525bd56db0
commit
6b5fb2dbc9
|
@ -17,6 +17,11 @@ withDefault default response =
|
|||
default
|
||||
|
||||
|
||||
parseError : String -> Maybe String
|
||||
parseError =
|
||||
Json.decodeString (field "error" Json.string) >> Result.toMaybe
|
||||
|
||||
|
||||
errorToString : Http.Error -> String
|
||||
errorToString err =
|
||||
case err of
|
||||
|
@ -27,11 +32,12 @@ errorToString err =
|
|||
"Network error"
|
||||
|
||||
BadStatus resp ->
|
||||
resp.status.message ++ " " ++ resp.body
|
||||
parseError resp.body
|
||||
|> Maybe.withDefault (resp.status.message ++ " " ++ resp.body)
|
||||
|
||||
BadPayload err resp ->
|
||||
-- OK status, unexpected payload
|
||||
"Unexpected response from api" ++ err
|
||||
"Unexpected response from api: " ++ err
|
||||
|
||||
BadUrl url ->
|
||||
"Malformed url: " ++ url
|
||||
|
|
|
@ -4,6 +4,7 @@ import Html exposing (..)
|
|||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onInput, onClick, onBlur)
|
||||
import Utils.FormValidation exposing (ValidationState(..), ValidatedField)
|
||||
import Utils.String
|
||||
|
||||
|
||||
tab : tab -> tab -> (tab -> msg) -> List (Html msg) -> Html msg
|
||||
|
@ -126,6 +127,5 @@ loading =
|
|||
|
||||
error : String -> Html msg
|
||||
error err =
|
||||
div []
|
||||
[ p [] [ text <| "Error: " ++ err ]
|
||||
]
|
||||
div [ class "alert alert-warning" ]
|
||||
[ text (Utils.String.capitalizeFirst err) ]
|
||||
|
|
|
@ -104,7 +104,7 @@ informationBlock silence alerts =
|
|||
Views.Shared.SilencePreview.view alerts
|
||||
|
||||
Utils.Types.Failure error ->
|
||||
div [ class "alert alert-warning" ] [ text error ]
|
||||
Utils.Views.error error
|
||||
|
||||
Utils.Types.Loading ->
|
||||
loading
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue