python-o365
python-o365 copied to clipboard
Catch detailed error messages
Hi Thanks for this cool module it really makes my life easier! Is there a way to capture the details on the Request Errors? For example, if I'm trying to refresh the token and an error occurs all I got is a "RuntimeError: Token Refresh Operation not working". My goal is to know whether it was a ConnectionError or an invalid request etc. Because the exceptions are captured and logged to the stdout, I'm unable to capture them.
Thanks, Ben
Yes, just set the logging to output the requests error messages.
Like:
import logging
logging.basicConfig(level=logging.DEBUG) # or whatever default level you want
requests_logger = logging.getLogger('requests')
requests_logger.setLevel(logging.ERROR)