Improve exception handling pattern