Skip to content

Commit ec5375f

Browse files
author
zmoody
committed
2 parents 50fb157 + c153faa commit ec5375f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pynetbox/lib/query.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ class RequestError(Exception):
2525
More detailed exception that returns the requests object. Along
2626
with some attributes with specific details from the requests
2727
object.
28+
29+
:Example:
30+
31+
>>> try:
32+
... nb.dcim.devices.create({'name': 'destined-for-failure'})
33+
... except pynetbox.RequestError as e:
34+
... print(e.error)
35+
...
36+
{"device_role":["This field is required."]}
37+
38+
39+
2840
"""
2941
def __init__(self, message):
3042
req = message

pynetbox/lib/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __getattr__(self, k):
7676
if self.has_details is False and k != 'keys':
7777
if self.full_details():
7878
ret = getattr(self, k, None)
79-
if ret:
79+
if ret or hasattr(self, k):
8080
return ret
8181

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

0 commit comments

Comments
 (0)