-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use custom unmarshalError handler for Route53 #438
Conversation
(for the record: I based this PR on 51ee380) |
Woooops, hadn't run |
Hi @abustany thanks for taking the time to create this PR. Adding error handling for these classes of errors will be a good addition to the SDK. To handle the composite errors I'd suggest creating a error sub type similar to I'll look through the SDK to see if batched errors can occur with other service API operations, but in the interim I think it makes sense for the base XML protocol parser to handle batched errors if it can be done generically. |
ok, thanks a lot for the guidance, I'll cook a patch based on that. Looking at the APIs I know from AWS (and quickly grepping through the JSON API specs), I can't really find any other kind of batched errors (S3 multi-delete for example still returns HTTP 200 even if some deletes fail). There are many AWS APIs I'm not familiar with though, so it's quite likely that I missed some. |
I wrote a quick and dirty go script to check errors structures across the various APIs: http://paste.fedoraproject.org/291392/76716614 (you can just |
Hi @abustany good idea to scan the models. I verified this as well Also it would be great to have some test cases of the custom error unmarshaller. |
apologies about the delay on that one, I still intend to fix that issue, but have higher priorities at work at the moment. |
Thanks for the update @abustany no rush, we'll keep this PR open for you. |
OK, here is a new version of the branch that adds a standard type to awserr for batched errors, and tests for route53 error unmarshalling. I'm still a bit unhappy about the unmarshalling code since it duplicates some of the code in the restxml package. If you're fine with me adding an additional method there to unmarshal an error from a given |
Looks pretty good, and thanks for adding the tests also! I agree getting rid of the duplication would be helpful. I know this is done for S3 and another service, but not adding additional duplication would be great. I'm curious what using a []byte instead of io.Reader would look like to remove the duplication. In other places where we've needed to rewind a stream type ByteReadCloser struct {
*bytes.Reader
}
func (b *ByteReadCloser) Close() error { return nil } This would more cleanly allow us to share the logic used for multi tiered error parsing. |
Certains Route53 calls like ChangeResourceRecordSets will return specific error types, so we need a custom handler to take those into account.
So I updated the branch again, it looks like in that case I can get away by simply "monkey patching" the |
Thanks for the update @abustany. The benefit of using the #331 highlights this issue where multiple error unmarshalling are helpful. |
Certains Route53 calls like ChangeResourceRecordSets will return
specific error types, so we need a custom handler to take those into
account.
Open questions:
awserr.Error
type doesn't account for "composite" errors, so for now I just join the messages with \n... Is there a better way to solve that issue?UnmarshalErrorFromData(statusCode int, body []byte) error
function there.