duplicate exception catching logic to code translation.