Enhance error message for Future.setErrorIfNeeded. (#56631)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56631
`setErrorIfNeeded` did not mention whether the future was already
completed or there was some other exception. This particular change ensures
that we also print out the original exception as part of the error message.
This would help in debugging issues where this codepath is triggered.
ghstack-source-id: 127248844
Test Plan: waitforbuildbot
Reviewed By: rohan-varma
Differential Revision: D27919974
fbshipit-source-id: 2273a93f3475929b14f721c976f194f33a5aa746