Skip to content

Refactor/better error handling#27

Merged
devoreofox merged 2 commits into
mainfrom
refactor/betterErrorHandling
Jul 12, 2026
Merged

Refactor/better error handling#27
devoreofox merged 2 commits into
mainfrom
refactor/betterErrorHandling

Conversation

@devoreofox

Copy link
Copy Markdown
Owner

Better error surfacing: non-throwing parser + unified diagnostics

Reworks how the plugin reports authoring errors, on two fronts: stop using exceptions for expected parse failures, and surface every problem consistently in one place.

Parser: exceptions to results

  • Tokenizer and Parser no longer throw. They report failures through a Condition.TryParse(expression, out node, out error) facade instead.
  • ConditionException is deleted, along with its four catch sites.
  • This matters most in the editor: the highlighter re-parses visible conditional lines every frame, so a half-typed :if used to throw and catch an exception ~60 times a second. That cost is now gone.

Structured diagnostics

  • New Diagnostic record (message, optional line number, severity) plus a Severity enum (Error, Warning).
  • The four validators (blocks, sets, waits, untils) now return IEnumerable<Diagnostic> instead of a single string?, so they report every problem rather than just the first.
  • New AliasValidator.Validate aggregator runs all validators and folds cycle detection into the same list.

One consistent surface

  • The alias editor now lists all current problems together, each with its line number and a color for its severity (red for errors, amber for warnings).
  • Cycle detection moved out of the trigger field's hover tooltip and into that panel, so a recursive alias is no longer hidden behind a mouseover. The tooltip is back to being pure help text.
  • Added a configurable Warning theme color (auto-picks up a settings swatch via the existing reflection). Today the only warning is a :until -unsafe used while unsafe waits are disabled.

Tests

  • ConditionEvaluatorTests: malformed expressions now assert a false result instead of a thrown exception.
  • AliasValidatorTests: updated to the new return type, plus coverage for per-line reporting and multiple diagnostics from one alias.

@devoreofox
devoreofox merged commit 69fd0c3 into main Jul 12, 2026
1 check passed
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