Return correct promise in error case