catch unhandled rejection with installation-handling (#3795)

This commit is contained in:
kahoona77
2017-05-09 14:10:38 +02:00
committed by Florent Vilmart
parent 8d67776c2e
commit 64e6f40779

View File

@@ -793,7 +793,15 @@ RestWrite.prototype.handleInstallation = function() {
if (this.data.appIdentifier) {
delQuery['appIdentifier'] = this.data.appIdentifier;
}
this.config.database.destroy('_Installation', delQuery);
this.config.database.destroy('_Installation', delQuery)
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored.
return;
}
// rethrow the error
throw err;
});
return;
}
} else {
@@ -806,6 +814,14 @@ RestWrite.prototype.handleInstallation = function() {
return this.config.database.destroy('_Installation', delQuery)
.then(() => {
return deviceTokenMatches[0]['objectId'];
})
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored
return;
}
// rethrow the error
throw err;
});
} else {
if (this.data.deviceToken &&
@@ -835,7 +851,15 @@ RestWrite.prototype.handleInstallation = function() {
if (this.data.appIdentifier) {
delQuery['appIdentifier'] = this.data.appIdentifier;
}
this.config.database.destroy('_Installation', delQuery);
this.config.database.destroy('_Installation', delQuery)
.catch(err => {
if (err.code == Parse.Error.OBJECT_NOT_FOUND) {
// no deletions were made. Can be ignored.
return;
}
// rethrow the error
throw err;
});
}
// In non-merge scenarios, just return the installation match id
return idMatch.objectId;