Fixed checking for onError function in wrong scope