I'm using Elm 0.18 and trying to convert http errors into strings.

The simple module below:

import Http exposing ( .. )

httpErrorString : Http.Error -> String
httpErrorString error =
    case error of
        Http.BadStatus ( Response response ) ->
            "bad status [" ++ response ++ "]"


 fails to compile with the following error:

Cannot find pattern `Response`

6|         Http.BadStatus ( Response response ) ->
                            ^^^^^^^^^^^^^^^^^


If I make the reference to Response explicit by prefixing Http. like this:

import Http exposing ( .. )


httpErrorString : Http.Error -> String
httpErrorString error =
    case error of
        Http.BadStatus ( Http.Response response ) ->
            "bad status [" ++ response ++ "]"

then I get this compilation error message:

Cannot find pattern `Http.Response`.

6|         Http.BadStatus ( Http.Response response ) ->
                            ^^^^^^^^^^^^^^^^^^^^^^
`Http` does not expose `Response`. 



My local elm-stuff/packages/elm-lang/http/1.0.0/src/Http.elm file clearly 
appears to export Response:

module Http exposing
  ( Request, send, Error(..)
  , getString, get
  , post
  , request
  , Header, header
  , Body, emptyBody, jsonBody, stringBody, multipartBody, Part, stringPart
  , Expect, expectString, expectJson, expectStringResponse, Response
  , encodeUri, decodeUri, toTask
  )


I don't understand the error in my pattern matching, nor the compiler's 
message about Response not being exported.

Can anyone explain what's going wrong here?

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to