[rpc] throw correct Exception on local client based on the RemoteException (#32936)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32936
Closes https://github.com/pytorch/pytorch/issues/32732. Currently if a
UDF run in RPC throws an exception such as ValueError or TypeError, we wrap
this in a RemoteException on the callee side. When raising this on the caller
side, we currently raise a vanilla Exception. This diff changes it so that the
correct exception is thrown. Tested by changing the current rpc tests to assert
on the right type of error rather than just the base `Exception`.
ghstack-source-id: 97706957
Test Plan: Modified unit test.
Differential Revision: D19700434
fbshipit-source-id: e451b772ea6aecc1d2e109e67e7f932eb9151f15