Skip to content

Commit 4383c4b

Browse files
ChrisBAshtonpatrickpatrickpatrick
authored andcommitted
WIP: Attempt to catch exception and show user error message
Following on from PR 10912 which raises an exception if a computed base path already exists in Publishing API for a live content item that has a different content ID... ...currently, we raise an exception in that case, and the user would just see a "Server Error" message. Ideally we'd want to catch that exception and show an error message to the user instead, nudging them to edit their title. Steps to test locally: 1. Set up a legacy published NewsArticle, with a slug (e.g. 'foo') 2. Try creating a new StandardEdition news article with a title that would end up generating the same slug (i.e. "Foo"). Currently, on step 2, locally I see the exception introduced in 10912. In this WIP commit I was expecting to catch the exception and surface the error to the user, and to still be on the "new document" screen (with my inputted values retained from the form submission). But instead, the draft gets created and the slug gets enumerated (in this example, "foo--2" or something like that). I'm not sure why the code I've added in this commit causes the draft to save successfully 🤔
1 parent bb90ade commit 4383c4b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

app/services/draft_edition_updater.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ def perform!
55
notify!
66
true
77
end
8+
rescue UnpublishableInstanceError => e
9+
@failure_reason = e.message
10+
false
811
end
912

1013
def failure_reason
14+
return @failure_reason if @failure_reason.present?
15+
1116
if !edition.pre_publication?
1217
"A #{edition.state} edition may not be updated."
1318
elsif should_check_current_user_will_retain_access? && access_limit_excludes_current_user?

0 commit comments

Comments
 (0)