python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Catch detailed error messages

Open bence-b opened this issue 3 years ago • 1 comments

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

bence-b avatar Mar 16 '22 20:03 bence-b

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)

alejcas avatar Mar 31 '22 11:03 alejcas