fix handling exceptions