caffe2: preserve python exception type from PythonOp (#36267)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36267
This makes PythonOp throw the original python exception instead of wrapping it in a c10::Error type. This allows throwing exceptions from Python and preserving the type when they're caught again in Python. This is important for structured logging and handling non-retryable error types.
Test Plan: buck test caffe2/caffe2/python:python_op_test
Reviewed By: wenqicaofb
Differential Revision: D20928098
fbshipit-source-id: 001747f022c657b420f8450b84d64f4d57f6cdf6