Parse error message (#866)

* Parse error message

* Update bindata.go
This commit is contained in:
Andrey Kuzmin 2017-06-18 12:19:40 +02:00 committed by stuart nelson
parent 525bd56db0
commit 6b5fb2dbc9
4 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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) ]

View File

@ -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