docusign / docusign-esign-python-client

The Official DocuSign Python Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client. https://www.docusign.com/devcenter
MIT License
96 stars 87 forks source link

ApiException causes no attribute 'trace_token' exception when trying to print it #177

Open jmrodri opened 11 months ago

jmrodri commented 11 months ago

The ApiException class has an optional http_resp parameter. It will then use the alternate construction which does not set the trace_token attribute.

Here is a reproducer:

from docusign_esign import ApiException
e = ApiException(status="status", reason="reason")
print(e)

Here is what I got when running it:

In [1]: from docusign_esign import ApiException

In [2]: e = ApiException(status="status", reason="reason")

In [3]: print(e)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-0c8bf275a22d> in <module>
----> 1 print(e)

~/.pyenv/versions/3.8.14-yardline/lib/python3.8/site-packages/docusign_esign/client/api_exception.py in __str__(self)
     38                         "Reason: {1}\n" \
     39                         "Trace-Token: {2}\n" \
---> 40                         "Timestamp: {3}\n".format(self.status, self.reason, self.trace_token, self.timestamp)
     41         if self.headers:
     42             error_message += "HTTP response headers: {0}\n".format(self.headers)

AttributeError: 'ApiException' object has no attribute 'trace_token'
jmrodri commented 11 months ago

After the patch it works:

(status)
Reason: reason
Trace-Token: None
Timestamp: None