make the errorHandler be a factory that takes a callback as an argument