Refine exception catching.