WIP: Attempt to catch exception and show user error message #10914
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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 🤔
This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.
Follow these steps if you are doing a Rails upgrade.