In Elm tutorial, Http section, there is code sample where defines the Cmd
for run-time to handle:
Http.get
{ url = "https://elm-lang.org/assets/public-opinion.txt"
, expect = Http.expectString GotText
}
So we expect server response to be text and pass the message type (GotText
) to Http.expectString
function so later the result would be attached to GotText
. Here is GotText
definition (it is of type: Result):
type Msg
= GotText (Result Http.Error String)
So if any error happens during request, plus the expected response type, it would be captured inside Http.Error
attached to GotText
, otherwise a run-time error happens (which is not true in ELm). My question is what if server returns something other that text, i.e. binary? AFAIK there doesn't exist such a Http error as bad response
, so is that type of error still embedded inside Http.Error
in ELm?