Handle JSON-based BotoServerError body strings well #1010

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

allardhoeve commented Sep 21, 2012

Hey there,

The current master handles XML error responses well. It fills the BotoServerError object quite nicely. But when JSON is returned, the JSON is just dumped into self.error_message.

I created a function _parseJSONBody(self, body) that handles this JSON. It works, for example, when CloudFormation tells you that your template parameters are invalid. Now the returned BotoServerError is consistent with other cases.

Please apply to master.

Best,

Allard

Owner

garnaat commented Nov 14, 2012

I would love to get this fixed. I'm concerned that this PR is making an assumption about the format of the JSON response that may not always be true. We should look across the services that do provide JSON errors and make sure the code is able to correctly pull the error code and error message out.

With body set to None, won't the repr (used in tracebacks) still be useless?

Why not set self.body to the error message.

Or maybe better yet, change repr to use error_message.

Good idea! I'll try to code this up in some spare time. That change is trivial, though, after pulling.

@allardhoeve allardhoeve closed this Sep 2, 2013

@allardhoeve allardhoeve deleted the ByteInternet:pull/servererror-handle-json-body branch Sep 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment