Improve exception check.