give exception a nice message (closes #22379)

Patch by Yongzhi Pan.
6 files changed