Skip to content

Conversation

@jmervine
Copy link

Addressing issue #11, sort of. Adding more verbose error messaging.

Conflicts:
	maxcdn/maxcdn.py
	test/test.py
@kdmny
Copy link

kdmny commented Dec 18, 2014

Thanks for looking into this. I like the idea of throwing a ServerError or something if the response status code is not in the 2xx range, packaging the raw response inside.

@jmervine
Copy link
Author

I like that idea. Just to be clear, you're suggesting added an additional property to the Exception, something like raw_response?

@kdmny
Copy link

kdmny commented Dec 18, 2014

Yup, That and some explicit exception type that we can catch that
differentiates this kind of error as a remote server error.
On Dec 18, 2014 1:08 PM, "Joshua Mervine" [email protected] wrote:

I like that idea. Just to be clear, you're suggesting added an additional
property to the Exception, something like raw_response?


Reply to this email directly or view it on GitHub
#12 (comment).

@jmervine
Copy link
Author

@kdmny Let me know what you think of the ServerError format I just added. It's more than discussed, but should be complete without being overkill.

Here's a basic example with a forced 404:

>> pprint(error)
ServerError(u'RWS\\Exception:: Resource not found at /jmervine/v3/badreporting/logs.json',)

>> pprint(error.__dict__)
{'body': '{"code":404,"error":{"message":"Resource not found at \\/jmervine\\/v3\\/badreporting\\/logs.json","type":"RWS\\\\Exception"}}',
 'code': 404,
 'headers': {'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'set-cookie': 'PHPSESSID=7orbutcud1kjh1ofr4i4kiggh0; path=/; secure; HttpOnly', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'vary': 'Accept-Encoding', 'server': 'nginx', 'connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'date': 'Thu, 18 Dec 2014 19:15:31 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'},
 'reason': u'RWS\\Exception',
 'url': u'https://rws.maxcdn.com/jmervine/v3/badreporting/logs.json?start=2014-12-18T11%3A14%3A31.174058'}

Here's a basic example with a forced ValueError:

>> pprint(err)
ServerError('No JSON object could be decoded',)

>> pprint(err.__dict__)
{'body': 'Some bad JSON content.',
 'code': 200,
 'headers': {'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'set-cookie': 'PHPSESSID=7orbutcud1kjh1ofr4i4kiggh0; path=/; secure; HttpOnly', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'vary': 'Accept-Encoding', 'server': 'nginx', 'connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'date': 'Thu, 18 Dec 2014 19:15:31 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'},
 'reason': 'Success',
 'url': 'http://www.example.com/foo/bar'}

@jmervine
Copy link
Author

@kdmny Unless you or anyone else has any issue with it, I'll release this as 0.0.5 later this afternoon. Cheers!

jmervine added a commit that referenced this pull request Dec 19, 2014
@jmervine jmervine merged commit 171765e into master Dec 19, 2014
@jmervine jmervine deleted the issues/11 branch December 19, 2014 17:54
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

Successfully merging this pull request may close these issues.

3 participants