give exception a nice message (closes #22379)

Patch by Yongzhi Pan.

--HG--
branch : 2.7
extra : amend_source : ba0b182b4565457a53d0d0495612d9c64cd5c0ef