refactor: createRef and parseRef with Improved Error Handling and Validation#1178
refactor: createRef and parseRef with Improved Error Handling and Validation#1178gwagjiug wants to merge 2 commits intoacacode:mainfrom
Conversation
|
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the createRef and parseRef functions to improve input validation and error handling.
- Added array type and empty check validations for createRef.
- Improved ref format check and detailed error messaging in parseRef.
Comments suppressed due to low confidence (2)
src/schema-components-map.ts:17
- [nitpick] Consider using a custom error class or a centralized error handler to provide more consistent and actionable error messages across similar functions.
if (!Array.isArray(paths)) {
src/schema-components-map.ts:27
- [nitpick] For consistency with the createRef function, consider unifying the error handling strategy by possibly reusing the same error construct or message formatting.
if (!ref.startsWith("#/")) {
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no bugs!
Bugbot free trial expires on September 2, 2025
Learn more in the Cursor dashboard.
PR Description
Changes
Added validation to ensure createRef accepts an array and is not empty.
Improved error handling for parseRef to check if the reference string starts with #/.
Both functions now throw detailed error messages when invalid inputs are provided, making debugging easier.
Why is this change needed?
The validation ensures the functions behave correctly, providing meaningful feedback when invalid input is passed.
This change improves the robustness of the SchemaComponentsMap class and provides better developer experience by catching errors earlier.