Last active
July 30, 2019 20:49
-
-
Save ababup1192/89c0d1e4a67d45004690f6f7f9209931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsonResolver : D.Decoder a -> Http.Resolver Http.Error a | |
jsonResolver decoder = | |
Http.stringResolver <| | |
\response -> | |
case response of | |
Http.BadUrl_ url -> | |
Err (Http.BadUrl url) | |
Http.Timeout_ -> | |
Err Http.Timeout | |
Http.NetworkError_ -> | |
Err Http.NetworkError | |
Http.BadStatus_ metadata body -> | |
Err (Http.BadStatus metadata.statusCode) | |
Http.GoodStatus_ metadata body -> | |
case D.decodeString decoder body of | |
Ok value -> | |
Ok value | |
Err err -> | |
Err (Http.BadBody (D.errorToString err)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment