-
Notifications
You must be signed in to change notification settings - Fork 211
feat(hsx): enhance HSX parser error messages with contextual suggestions (#916) #2100
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
base: master
Are you sure you want to change the base?
Conversation
- Add ErrorMessage module for improved error reporting - Implement fuzzy matching for common tag/attribute typos - Add comprehensive error suggestions and helpful context - Maintain backward compatibility with existing parser - Add test coverage for enhanced error scenarios Fixes common developer pain points when debugging HSX templates.
- Remove invalid Data.Text.Lines import - Fix NonEmpty pattern matching syntax - Correct error type references in Parser.hs - Clean up test imports and expectations - Ensure all modules compile successfully The enhanced error message system now compiles correctly. Some tests may need adjustment for exact message matching.
- Add new ErrorMessage module with intelligent error classification - Implement detailed error reporting with actionable suggestions - Support for invalid tags, attributes, and syntax errors - Provide HTML standard guidance and alternative solutions - Update parser to integrate enhanced error messages - Add comprehensive test coverage for error scenarios Fixes digitallyinduced#916
Demonstrates before/after error message improvements for issue digitallyinduced#916 - Invalid tag name errors with suggestions - Invalid attribute name errors with guidance - Duplicate attribute detection - Significantly improved developer experience
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 implements enhanced error messages for the HSX parser to provide contextual suggestions and improve developer experience. The implementation addresses bounty issue #916 by adding a new error message module and integrating it into the existing parser.
- Added comprehensive error classification and suggestion system for HSX parsing errors
- Enhanced existing parser error points to provide contextual feedback and actionable suggestions
- Extended test coverage to verify enhanced error message functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| IHP/HSX/ErrorMessage.hs | New module providing error classification, context extraction, and suggestion generation |
| IHP/HSX/Parser.hs | Enhanced existing parser with new parseHsxWithEnhancedErrors function and improved error messages at key failure points |
| ihp-hsx.cabal | Added new ErrorMessage module to library exports |
| Test/IHP/HSX/ParserSpec.hs | Updated tests to verify enhanced error messages and added comprehensive test cases |
| DEMO_DETAILED.md | Documentation showing before/after examples of error message improvements |
Comments suppressed due to low confidence (1)
ihp-hsx/Test/IHP/HSX/ParserSpec.hs:194
- The test assumes a specific suggestion format for 'spn' but the
suggestSimilarTagfunction returns "div, span, or check the HTML specification" for unknown tags. This test may be brittle if the suggestion algorithm changes.
errorMessage `shouldContain` "div, span"
- Replace undefined errorOffset with proper Megaparsec error handling - Improve attribute extraction from error messages with robust parsing - Add boundary check for pointer calculation to prevent negative replication - Enhance error position extraction from parse error bundles Addresses code review feedback for improved robustness and reliability.
Summary
This PR implements a new module
IHP.HSX.ErrorMessageand enhances the HSX parser to provide contextual error messages. It addresses the bounty issue #916.Changes Made
IHP.HSX.ErrorMessageproviding smart error classification and suggestions.IHP.HSX.Parserto integrate contextual error messages.ihp-hsx.cabalto include the new module.ParserSpec.hswith tests covering new scenarios and verifying the improved messages.Features
ToHtmlinstances).uncheckedHsxfor custom tags) when appropriate.Tests & Validation
DEMO_DETAILED.md) with before/after examples and screenshots.Impact
fixes #916
/claim #916