From 512808e8b4c45b952bc5771d9e013b30108f1a89 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 15 Aug 2017 11:06:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Added=20409=20UpdateCollisionErr?= =?UTF-8?q?or=20for=20the=20editor=20(#8899)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- core/server/errors.js | 6 ++++++ core/server/models/plugins/collision.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/server/errors.js b/core/server/errors.js index 5b4828f7ed..bb5964aa7f 100644 --- a/core/server/errors.js +++ b/core/server/errors.js @@ -60,6 +60,12 @@ var ghostErrors = { statusCode: 409, errorType: 'DisabledFeatureError', }, options)); + }, + UpdateCollisionError: function UpdateCollisionError(options) { + GhostError.call(this, _.merge({ + statusCode: 409, + errorType: 'UpdateCollisionError', + }, options)); } }; diff --git a/core/server/models/plugins/collision.js b/core/server/models/plugins/collision.js index 00a52bc635..fa43f8f487 100644 --- a/core/server/models/plugins/collision.js +++ b/core/server/models/plugins/collision.js @@ -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' }));