[Checkins] SVN: z3c.json/trunk/ More informative error message when the server returns an error.

Marius Gedminas cvs-admin at zope.org
Tue Feb 26 11:52:36 UTC 2013


Log message for revision 129828:
  More informative error message when the server returns an error.
  
  Also some unused import and PEP-8 cleanups.
  
  

Changed:
  U   z3c.json/trunk/CHANGES.txt
  U   z3c.json/trunk/src/z3c/json/README.txt
  U   z3c.json/trunk/src/z3c/json/proxy.py

-=-
Modified: z3c.json/trunk/CHANGES.txt
===================================================================
--- z3c.json/trunk/CHANGES.txt	2013-02-26 11:52:11 UTC (rev 129827)
+++ z3c.json/trunk/CHANGES.txt	2013-02-26 11:52:36 UTC (rev 129828)
@@ -5,7 +5,7 @@
 0.5.5 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- More informative error message when the server returns an error.
 
 
 0.5.4 (2010-08-30)

Modified: z3c.json/trunk/src/z3c/json/README.txt
===================================================================
--- z3c.json/trunk/src/z3c/json/README.txt	2013-02-26 11:52:11 UTC (rev 129827)
+++ z3c.json/trunk/src/z3c/json/README.txt	2013-02-26 11:52:36 UTC (rev 129828)
@@ -22,7 +22,7 @@
 Read some data:
 
   >>> input = {u'a': ['fred', 7],
-  ...          u'b':['mary', 1.234]}
+  ...          u'b': ['mary', 1.234]}
   >>> jsonStr = jsonWriter.write(input)
   >>> jsonStr
   u'{"a":["fred",7],"b":["mary",1.234]}'

Modified: z3c.json/trunk/src/z3c/json/proxy.py
===================================================================
--- z3c.json/trunk/src/z3c/json/proxy.py	2013-02-26 11:52:11 UTC (rev 129827)
+++ z3c.json/trunk/src/z3c/json/proxy.py	2013-02-26 11:52:36 UTC (rev 129828)
@@ -16,12 +16,8 @@
 """
 __docformat__ = "reStructuredText"
 
-import string
 import urllib
-import httplib
 import copy
-import base64
-import types
 import logging
 import socket
 
@@ -147,14 +143,16 @@
             logger.error('Received status code %s' % response)
         elif len(response) == 3:
             # that's a valid response format
-            if self.jsonId is not None and \
-                (self.jsonId != response.get('id')):
+            if (self.jsonId is not None and
+                response.get('id') is not None and
+                self.jsonId != response.get('id')):
                 # different request id returned
                 raise ResponseError("Invalid request id returned")
             if response.get('error'):
                 # error mesage in response
                 self.error = response['error']
-                raise ResponseError("Check proxy.error for error message")
+                raise ResponseError("Received error from server: %s" %
+                                    self.error)
             else:
                 # only return the result if everything is fine
                 return response['result']



More information about the checkins mailing list