fix a case of potentially use of undefined variable when handling error in distributed message processing (#51019)
There is a use of `oldstate` on line 244 which has the possibility of
being undefined. This bug seems to have been introduced in
https://github.com/JuliaLang/julia/commit/40c622b7e66a88c05d8892222126f1d13851bc62#diff-39fa44ff86c5b38bd6b9e7f60733b25724a9efd9221ca38f776ed3f3ab01dec2.
I don't have a repro for this but this PR reverts back to the situation
where `oldstate` is defined at the topmost level of the catch block as
it was before the offending commit.
(cherry picked from commit 777b784dde077defd0aea58b598241f95146152a)