Last active
April 4, 2019 07:45
-
-
Save jzxhuang/6470a74ecef6b5e5a7f05c431128bc62 to your computer and use it in GitHub Desktop.
An expectString function with a more detailed successful response and error.
This file contains 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
-- Change this to return Result ErrorDetailed ( Http.Metadata, String ) instead of Result Http.Error ( Http.Metadata, String ) | |
convertResponseString : Response String -> Result ErrorDetailed ( Metadata, String ) | |
convertResponseString httpResponse = | |
case httpResponse of | |
Http.BadUrl_ url -> | |
Err (BadUrl url) | |
Http.Timeout_ -> | |
Err Timeout | |
Http.NetworkError_ -> | |
Err NetworkError | |
Http.BadStatus_ metadata body -> | |
Err (BadStatus metadata body) | |
Http.GoodStatus_ metadata body -> | |
Ok ( metadata, body ) | |
-- Update this function's type signature accordingly | |
expectStringDetailed : (Result ErrorDetailed ( Metadata, String ) -> msg) -> Expect msg | |
expectStringDetailed msg = | |
Http.expectStringResponse msg convertResponseString | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment