rapidpro / rapidpro-python

Python client library for the RapidPro API
BSD 3-Clause "New" or "Revised" License
18 stars 27 forks source link

TembaSerializationException always has the message <exception str() failed> #65

Closed toolness closed 4 years ago

toolness commented 4 years ago

Hello,

I was using the TembaObject.deserialize() method to deserialize archived Run objects in my project (https://github.com/JustFixNYC/tenants2/pull/902) and noticed that an unusual exception was occurring. It's easily reproducible in the REPL:

>>> from temba_client.serialization import TembaSerializationException
>>>
>>> raise TembaSerializationException('boop')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
temba_client.exceptions.TembaSerializationException: <exception str() failed>

The actual cause of str() failing can be found via:

>>> str(TembaSerializationException('boop'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.8/site-packages/temba_client/exceptions.py", line 3, in __str__
    return self.message
AttributeError: 'TembaSerializationException' object has no attribute 'message'

So it looks like .message isn't being set in the constructor for TembaSerializationException? For now I'm just catching the exceptions and logging their args[0] attribute, but fixing these so they have meaningful error messages would be helpful.

rowanseymour commented 4 years ago

Hey @toolness this does look like a bug.. wanna make a PR? 😃

toolness commented 4 years ago

Sure, l can try busting one up! It may be a few days though, I need to finish up some other things first...