File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
python/neutron-understack/neutron_understack Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ class NautobotCustomFieldNotFoundError(exc.NeutronException):
26
26
message = "Custom field with name %(cf_name)s not found for %(obj)s"
27
27
28
28
29
+ def _truncated (message : str | bytes , maxlen = 200 ) -> str :
30
+ input = str (message )
31
+ if len (input ) <= maxlen :
32
+ return input
33
+
34
+ return f"{ input [:maxlen ]} ...{ len (input ) - maxlen } more chars"
35
+
36
+
29
37
class Nautobot :
30
38
"""Basic Nautobot wrapper because pynautobot doesn't expose plugin APIs."""
31
39
@@ -60,7 +68,8 @@ def make_api_request(
60
68
try :
61
69
response_data = response .json ()
62
70
except requests .exceptions .JSONDecodeError :
63
- response_data = {"body" : response .content }
71
+ response_data = {"body" : _truncated (response .content )}
72
+
64
73
else :
65
74
response_data = {"status_code" : response .status_code , "body" : "" }
66
75
You can’t perform that action at this time.
0 commit comments