[Misc] Fix deprecated call.

* Improve an exception message.