TST: Implement external error raised helper function.
- [x] ref #30999
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Opened PR for what @gfyoung wrote [here](https://github.com/pandas-dev/pandas/issues/30999#issuecomment-575426086)