Hi,
I am using python logging module to log errors. I have a try-except block in my code where I catch OpenAI API call errors in there and log them into a script. The logging works fine when I test it with different messages, etc. However, it doesn’t log the OpenAI error, you can see in below.
try:
pass
except Exception as e:
logger.error(f"“” This is the OpenAI error: {e} “”")
print(e)
If I print out the error, the output is:
Error code: 404 - {‘error’: {‘message’: “No assistant found with id ‘asst_i2oWqFqSLXXxlS1YR4LcjKzGhE’.”, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}
Note that I am not looking for ways to fix the error, but rather, I am looking for a way to be able to log that error! I would appreciate your help with this. Thank you.
PS - indentation in the code is correct, it just doesn’t work in this forum.