PyImgur icon indicating copy to clipboard operation
PyImgur copied to clipboard

Do not print anything on error raise an exception instead

Open gcq opened this issue 10 years ago • 0 comments

Change this code this code to raise an exception instead of printing to stdout

if not resp.ok:
        try:
            error_msg = "Imgur ERROR message: {}".format(content['error'])
            print(error_msg)
            print("-" * len(error_msg))
        except Exception:
            pass
        resp.raise_for_status()

eg:

if not resp.ok:
        try:
            raise ImgurException("Imgur ERROR message: {}".format(content['error']))
        except Exception:
            resp.raise_for_status()

gcq avatar Jun 18 '14 22:06 gcq