Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples for handling BadStatus Http.Error with Response Body #59

Open
AntonLebiodkin opened this issue Mar 4, 2019 · 2 comments
Open

Comments

@AntonLebiodkin
Copy link

Hi, folks!
We have our Elm app where the server sends to us some objects with validation errors in them with BadStatus.
Previously we handled response body from BadStatus Http.Error. But after contract change in elm/http (previously evancz/elm-http), we can't figure out how to get it correctly.

P.S. We're using Http.task, so seems we can't add there expect field to get additional info, cause it exists only on Http.request

@alex-tan
Copy link

@AntonLebiodkin there's some explanation here. You can replace Http.Error with your own custom error type and in the BadStatus case attempt to run a decoder on the body to get the validation errors.

@jjagielka
Copy link

There's no issue of creating your own version of Http.Error and extend the handling of missing 400 - body responses.
The problem is with usage of third party packages like RemoteData. Those packages import Http.Error directly and are not aware about the custom handlers you've created. This force you to copy paste a lot of type declarations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants