[Futures] Allow setErrorIfNeeded arg to have type FutureError (#39113)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39113
`setError` is overloaded - it can either take `FutureError` or an error message string as an argument. This PR replicates the same behavior for `setErrorIfNeeded`.
ghstack-source-id: 105038824
Test Plan: Sandcastle/CI
Differential Revision: D21753988
fbshipit-source-id: 0f413afd667f0416400aa95f0b2271b286326ac5