Repository navigation
Show the error message when creating a guest author fails - #192
Merged
Merged
Conversation
#142 changed the catch handler to call json() on the rejection, assuming apiFetch rejects with a Response. With the default parse option apiFetch rejects with the parsed error object instead, so json() threw a TypeError inside the catch and no notice was shown at all. Before #142 the message did show on WordPress 7.1. The handler now reads the message from the parsed error, and only calls json() when the rejection really is a Response, which keeps the case #142 was written for. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
johnbillion
approved these changes
Oct 19, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the missing error notice when creating a guest author fails.
#142 changed the catch handler in
src/components/AuthorsSelect.tsxto call.json()on the error. ButapiFetchrejects with the already-parsed error object, so.json()throws a TypeError. The editor then shows no notice when a user without thecreate_guest_authorscapability tries to create a guest author. Before #142 the message did show.The handler now uses
error.message. It only calls.json()when the rejection is a realResponse.Checked in WordPress Playground (WP 7.1, PHP 8.2), using a mu-plugin that removes
create_guest_authors:TypeError: e.json is not a function.With #142, no notice shows:
With this fix, the notice shows:
With this fix, creating a guest author normally still works:
Refs #141 and #142.
🤖 Generated with Claude Code