Add onErr(...) function.