Move exception initialization out of the try block.