Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/digitalocean/pynetbox
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoody committed Feb 28, 2018
2 parents 50fb157 + c153faa commit ec5375f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pynetbox/lib/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ class RequestError(Exception):
More detailed exception that returns the requests object. Along
with some attributes with specific details from the requests
object.
:Example:
>>> try:
... nb.dcim.devices.create({'name': 'destined-for-failure'})
... except pynetbox.RequestError as e:
... print(e.error)
...
{"device_role":["This field is required."]}
"""
def __init__(self, message):
req = message
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/lib/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __getattr__(self, k):
if self.has_details is False and k != 'keys':
if self.full_details():
ret = getattr(self, k, None)
if ret:
if ret or hasattr(self, k):
return ret

raise AttributeError('object has no attribute "{}"'.format(k))
Expand Down

0 comments on commit ec5375f

Please sign in to comment.