Update exception handling to use `except X as Y` syntax.