improve performance of error handling by masking custom handler