🐛 Added 409 UpdateCollisionError for the editor (#8899)

fixes #8898

- This is a user error, not a system error
- Downgrading to a 4xx status code means it doesn't appear in logs where it shouldn't
- We didn't have a suitable error available so I added UpdateCollisionError with 409 status
This commit is contained in:
Hannah Wolfe 2017-08-15 11:06:40 +01:00 committed by Sebastian Gierlinger
parent 340532136e
commit 512808e8b4
2 changed files with 7 additions and 1 deletions

View File

@ -60,6 +60,12 @@ var ghostErrors = {
statusCode: 409,
errorType: 'DisabledFeatureError',
}, options));
},
UpdateCollisionError: function UpdateCollisionError(options) {
GhostError.call(this, _.merge({
statusCode: 409,
errorType: 'UpdateCollisionError',
}, options));
}
};

View File

@ -55,7 +55,7 @@ module.exports = function (Bookshelf) {
if (Object.keys(changed).length) {
if (clientUpdatedAt.diff(serverUpdatedAt) !== 0) {
return Promise.reject(new errors.InternalServerError({
return Promise.reject(new errors.UpdateCollisionError({
message: 'Saving failed! Someone else is editing this post.',
code: 'UPDATE_COLLISION'
}));