Enhance exception handling