Added a user-configureable callback function for the errors.