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

Return Error Messages - AWS mostly gives 400 error codes with message in the body. #2

Open
rupertlssmith opened this issue Mar 13, 2020 · 1 comment

Comments

@rupertlssmith
Copy link

@rupertlssmith rupertlssmith commented Mar 13, 2020

The send functions look like:

send : Service -> Credentials -> Request a -> Task Error a

Which only returns Http.Error in the event of an error, and this only gives BadStatus 400 in the event of an AWS error. Would be better to define an Error type specifically for this package, that also gives back the AWS errors.

Workaround: Use https://package.elm-lang.org/packages/the-sett/elm-aws-core/latest/AWS-Core-Http#setResponseParser

@rupertlssmith

This comment has been minimized.

Copy link
Author

@rupertlssmith rupertlssmith commented Mar 13, 2020

Http.Error is:

type Response body
    = BadUrl_ String
    | Timeout_
    | NetworkError_
    | BadStatus_ Metadata body
    | GoodStatus_ Metadata body

And this is reduced to Http.Error which is:

type Error
    = BadUrl String
    | Timeout
    | NetworkError
    | BadStatus Int
    | BadBody String

Propsed AWS.Core.Http.Error might look like:

type Error
    = BadUrl String
    | Timeout
    | NetworkError
    | BadStatus Int
    | BadBody String
    | AWSError Int String

Where the 400 responses with a message get turned into AWSError 400 "Something went wrong".
BadStatus would still be there for capturing the 500 error codes.

Need to look in a bit more detail into exactly what error messages AWS can return? Is it always 400 and a string error message?

  • What about the REST-JSON APIs, do they use a range of status codes or the same everything is a 400 approach?

  • Are the error messages more complex, and require decoders?

  • What about the XML based APIs, do they return error messages in XML format?

Maybe need to define an AWSErrorMessage type which captures all the possibilities.

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.