http icon indicating copy to clipboard operation
http copied to clipboard

Accessing `Http.Error` with task requests

Open dullbananas opened this issue 5 years ago • 1 comments

task doesn't appear to provide any way of getting Http.Error values when errors occur.

dullbananas avatar Jul 04 '20 04:07 dullbananas

https://github.com/elm/http/blob/34a9a27411c2492d3e247ac75cd48e22b473bef5/src/Http.elm#L538-L543

important values like response body when http status != 2xx and http headers are not stored in the Http.Error values at all

Alternatives are

  • https://package.elm-lang.org/packages/jzxhuang/http-extras/latest/Http-Detailed#Error

    type Error body
        = BadUrl String
        | Timeout
        | NetworkError
        | BadStatus Http.Metadata body
        | BadBody Http.Metadata body String
    
  • https://package.elm-lang.org/packages/choonkeat/elm-ext-http/latest/Ext-Http#Error

    type Error a
        = BadUrl String
        | Timeout
        | NetworkError
        | BadStatus Http.Metadata a
        | BadJson Http.Metadata a Json.Decode.Error
    

choonkeat avatar Jan 18 '23 07:01 choonkeat