Reduce code duplication in callback comparator error handling