Skip to content

Commit

Permalink
Merge pull request versae#58 from esplorio/master
Browse files Browse the repository at this point in the history
Fix typo as well as better debug messages
Thanks to @necaris. It will be in the next release.
  • Loading branch information
versae committed Mar 10, 2012
2 parents 3f5587f + cd75bf0 commit 81dc662
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions neo4jrestclient/client.py
Expand Up @@ -761,7 +761,12 @@ def __setitem__(self, key, value, tx=None):
elif response.status == 404:
raise NotFoundError(response.status, "Node or property not found")
else:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content).get('message')
except (ValueError, AttributeError, KeyError):
pass
raise StatusException(response.status, msg)

def set(self, key, value, tx=None):
tx = Transaction.get_transaction(tx)
Expand All @@ -782,9 +787,9 @@ def __delitem__(self, key, tx=None):
raise KeyError()
else:
raise NotFoundError(response.status,
"Node or propery not found")
"Node or property not found")
else:
raise StatusException(response.status, "Node or propery not found")
raise StatusException(response.status, "Node or property not found")

def __len__(self):
return len(self._dic["data"])
Expand Down Expand Up @@ -839,7 +844,12 @@ def _set_properties(self, props={}):
self._update_dict_data()
return props
elif response.status == 400:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content).get('message')
except (ValueError, AttributeError, KeyError):
pass
raise StatusException(response.status, msg)
else:
raise NotFoundError(response.status, "Properties not found")

Expand Down Expand Up @@ -976,7 +986,12 @@ def relationship(to, *args, **kwargs):
"URI not of \"to\" node" \
"not found")
else:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content).get('message')
except (ValueError, AttributeError, KeyError):
pass
raise StatusException(response.status, msg)
return relationship

# HACK: Special methods for handle pickling manually
Expand Down Expand Up @@ -1092,7 +1107,12 @@ def traverse(self, types=None, order=None, stop=None, returnable=None,
raise NotFoundError(response.status, "Node or relationship " \
"not found")
else:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content).get('message')
except (ValueError, AttributeError, KeyError):
pass
raise StatusException(response.status, msg)


class PaginatedTraversal(object):
Expand Down Expand Up @@ -1225,7 +1245,12 @@ def create(self, name, **kwargs):
auth=self._auth,
**result_dict)
else:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content).get('message')
except (ValueError, AttributeError, KeyError):
pass
raise StatusException(response.status, msg)
return self._dict[name]

def get(self, attr, *args, **kwargs):
Expand Down Expand Up @@ -1923,7 +1948,12 @@ def __call__(self, *args, **kwargs):
elif response.status == 404:
raise NotFoundError(response.status, "Extension not found")
else:
raise StatusException(response.status, "Invalid data sent")
msg = "Invalid data sent"
try:
msg += ": " + json.loads(content)['message']
except (ValueError, AttributeError, KeyError, TypeError):
pass
raise StatusException(response.status, msg)

def __repr__(self):
return self.__unicode__()
Expand Down

0 comments on commit 81dc662

Please sign in to comment.