Changed API Class to accept closures as the error_function