diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-18 03:10:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-18 03:10:37 +0300 |
commit | 5ee9033e9db11ce04f5cc6d7bda32f8059a1f405 (patch) | |
tree | 37a34a5ecc9c5c4cb3338e2f8eb12409891bd1f4 /app/services/wiki_pages | |
parent | cd8520845d9205622b5acf301b68c0ac7d81aaec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/wiki_pages')
-rw-r--r-- | app/services/wiki_pages/update_service.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/services/wiki_pages/update_service.rb b/app/services/wiki_pages/update_service.rb index f2fc6b37c34..88275f8c417 100644 --- a/app/services/wiki_pages/update_service.rb +++ b/app/services/wiki_pages/update_service.rb @@ -2,6 +2,8 @@ module WikiPages class UpdateService < WikiPages::BaseService + UpdateError = Class.new(StandardError) + def execute(page) # this class is not thread safe! @old_slug = page.slug @@ -10,11 +12,15 @@ module WikiPages execute_hooks(page) ServiceResponse.success(payload: { page: page }) else - ServiceResponse.error( - message: _('Could not update wiki page'), - payload: { page: page } - ) + raise UpdateError, s_('Could not update wiki page') end + rescue UpdateError, WikiPage::PageChangedError, WikiPage::PageRenameError => e + page.update_attributes(@params) # rubocop:disable Rails/ActiveRecordAliases + + ServiceResponse.error( + message: e.message, + payload: { page: page } + ) end def usage_counter_action |