[Caffe2] raise exceptions instead of str (#37744)
Summary:
Some exceptions are not correctly wrapped inside a class.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37744
Differential Revision: D21388197
Pulled By: mrshenli
fbshipit-source-id: 2d69e2543c2e05116c367d137968b982c254d2dc