Closed vaurdan closed 1 month ago
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Description
This PR improves the error handling of the Excerpt Suggestions feature, and updates it to extend the provider from the BaseProvider. The Generate button will also be disabled when the post content is empty. On the other hand, if the title is empty, since it's still possible to generate an excerpt, it will use the 'Untitled' as a title placeholder.
As a note, the CS API returns the error message as an array if there is an validation error, for example:
The BaseProvider will test if the message is an object, and if so, it will use the first entry of the
message
object as the one to create the ContentHelperError object.Motivation and context
Improve the reliability of the Excerpt Suggestions feature, preventing the block editor from crashing on unexpected errors.
How has this been tested?
Tested locally with an empty post, and a regular post.
Summary by CodeRabbit
Bug Fixes
BaseProvider
class.ExcerptPanel
component, specifically targetingContentHelperError
.New Features
getInstance()
method for singleton instance retrieval in theExcerptGeneratorProvider
class.ExcerptGeneratorProvider
to handle empty titles by setting them to 'Untitled'.