torchbox / wagtail-wordpress-import

A package for Wagtail CMS to import WordPress blog content from an XML file into Wagtail
MIT License
44 stars 16 forks source link

RequestException is the base class exception? #134

Open nickmoreton opened 2 years ago

nickmoreton commented 2 years ago

Suggestion:

I believe RequestException is the base class exception so if you want to keep it specific then it might be better to put this one last https://stackoverflow.com/a/47007419

I've added some snippets below which could work to shorten the code a little but I haven't got a lot of experience with exepction handling so not sure if they would be considered bad practise or not:

    except (requests.ConnectionError, requests.HTTPError, requests.ReadTimeout, requests.Timeout, requests.ConnectTimeout, requests.RequestException) as e :
        print(f"{type(e).__name__}: {src}")
        return None, False, None

or

    except Exception as e:
        print(f"{type(e).__name__}: {src}")
        return None, False, None

_Originally posted by @Morsey187 in https://github.com/torchbox/wagtail-wordpress-import/pull/125#discussion_r774991305_

nickmoreton commented 2 years ago

@Morsey187 Hi Ben. When you have a chance would you be able to review the PR I created for this issue you raised. Thanks Nick