ConvertAPI / convertapi-library-python

A Python library for the ConvertAPI
https://www.convertapi.com
Other
77 stars 22 forks source link

The API is working fine but there is a message error (part of API Error) that stops the rest of my program from running #7

Closed machelreid closed 4 years ago

mayaizart commented 4 years ago

I'll be more specific as I've found where the issue is. When some sort of error occurs and an ApiError is thrown the following exception is thrown:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/convertapi/exceptions.py", line 14, in __str__
    message = "%s Code: %s. %s" % (self.message, self.code, self.invalid_parameters)     
AttributeError: 'ApiError' object has no attribute 'message'

The issue is that self.message is never defined in ApiError, therefore __str__fails. Adding self to where message is defined in __init__ will fix the issue.

tomasr78 commented 4 years ago

My idea is that the problem appears when response does not has an actual response model and API error json model binding fails. It could happen when server return 500 for some unknown reason.

mayaizart commented 4 years ago

In my case I realised this issue when we sent a faulty file path. Only after making the change above I could see the actual error that was returned which was code 5007 - Unable to download remote file'. So that's not a random 500 error.

laurynas-convertapi commented 4 years ago

Thanks @mayaizart for the fix PR. Merged and released 1.1.1 version.