-
Couldn't load subscription status.
- Fork 32
Refactor error handling in REST API run controller #31
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
Conversation
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.
Pull Request Overview
This PR standardizes error handling in the REST API abilities run controller by introducing consistent error codes for different types of validation failures and moving validation logic from the REST controller into the core WP_Ability class.
- Replaced generic REST error codes with specific ability-related error codes for better error identification
- Moved input/output validation from REST controller to WP_Ability class to centralize validation logic
- Updated permission handling to properly propagate input validation errors
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
includes/rest-api/endpoints/class-wp-rest-abilities-run-controller.php |
Removed duplicate validation methods and updated error codes for method and permission checks |
includes/abilities-api/class-wp-ability.php |
Enhanced validation methods to return standardized WP_Error objects and improved error propagation in execute method |
tests/unit/rest-api/wpRestAbilitiesRunController.php |
Updated test assertions to expect new standardized error codes |
tests/unit/abilities-api/wpRegisterAbility.php |
Updated test assertions and removed expected incorrect usage warnings |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Code lgtm and tests passing locally too 🚀
(I know you marked this in-progress, but it looks complete to me 😇)
|
I forgot to remove in progress status 😄 Yes, it should be ready to land. |
WP_ErrorfromWP_Abilitymethods #23It addresses the following refactoring:
This PR standardizes error handling in the REST API abilities run controller by introducing consistent error codes for different types of validation failures and moving validation logic from the REST controller into the core WP_Ability class.
Testing
Run
npm run test:phpand make sure all tests pass.