Skip to content

Improve error handling with readable messages - #5

Draft
eykd wants to merge 1 commit into
masterfrom
improve-error-handling
Draft

Improve error handling with readable messages#5
eykd wants to merge 1 commit into
masterfrom
improve-error-handling

Conversation

@eykd

@eykd eykd commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wrap parsimonious exceptions: parsers.parse() now catches ParsimoniousParseError and VisitationError, re-raising as syml.exceptions.ParseError with raise ... from e. Callers no longer need to import parsimonious to handle parse errors.
  • Structured error messages: OutOfContextNodeError now produces compiler-style messages like test.syml:3:2: unexpected indentation: - baz, including filename when available. ParseError also threads filename into the message.
  • Public exception exports: ParseError and OutOfContextNodeError are now importable directly from syml.
  • Dead code removal: Removed unreachable return in Source.__add__.

Test plan

  • Existing tests pass (33/33, 100% coverage)
  • New test: OutOfContextNodeError message includes "unexpected indentation"
  • New test: OutOfContextNodeError includes filename when provided
  • New test: visitor errors are wrapped as syml.ParseError, not raw VisitationError
  • New test: wrapped errors include filename
  • New test: wrapped errors chain the original exception via __cause__

🤖 Generated with Claude Code

…tions

- Add structured ParseError with filename support for compiler-style messages
- OutOfContextNodeError now formats as 'file:line:col: unexpected indentation: ...'
- Wrap parsimonious ParseError/VisitationError in syml.ParseError so callers
  don't need to import parsimonious to catch parse errors
- Export ParseError and OutOfContextNodeError from syml package
- Remove dead code (unreachable return in Source.__add__)
- Add tests for error message content, filename threading, and exception chaining

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant