ENH: Improve error message for empty object array
Improve the error message shown when an object array is empty

closes #23572

- [x] closes #23572
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


No what's new since too small a change and no test needed.