-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Title Optimization: improve error handling #39340
Title Optimization: improve error handling #39340
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
… free and paid plan quotas
@@ -58,7 +103,7 @@ export default function TitleOptimization( { | |||
const [ isTitleOptimizationModalVisible, setIsTitleOptimizationModalVisible ] = useState( false ); | |||
const [ generating, setGenerating ] = useState( false ); | |||
const [ options, setOptions ] = useState( [] ); | |||
const [ error, setError ] = useState( false ); | |||
const [ error, setError ] = useState< TitleOptimizationError >( null ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [ error, setError ] = useState< TitleOptimizationError >( null ); | |
const [ error, setError ] = useState< TitleOptimizationError | null >( null ); |
} | ||
|
||
// Use the provided message, if available, otherwise use the generic error message | ||
const errorMessage = error?.message ? error.message : genericErrorMessage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const errorMessage = error?.message ? error.message : genericErrorMessage; | |
const errorMessage = error.message ? error.message : genericErrorMessage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just left a couple type comments
* Save the error object so we can use it to display the error message * Move error message to it's own component * Show the provided error message when the error is related to moderation * Use an error notice to show the errors * Show FairUsageNotice when the error is a quota exceeded one * Changelog * Use the QuotaExceededMessage component so we handle automatically the free and paid plan quotas * Support JSON error handling * Reuse the generic error message * Change code to trust the message provided by the error object, when available * Do not show retry button when the error will not go away * Include type suggestions
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
public-api
domainbeta
blocks variationjetpack-ai-query
endpoint handler; add the snippet as the first line of therun_query
methodTesting the moderation error
Improve title for SEO
buttonTesting the JSON parsing error
Testing the quota exceeded error on a free site
0-sandbox.php
file:Improve title for SEO
button yet0-sandbox.php
file and change the snippet to:Improve title for SEO
Testing the quota exceeded error on a paid site
0-sandbox.php
file:Improve title for SEO
button yet0-sandbox.php
file and change the snippet to:Improve title for SEO