Skip to content

Improve error messages for invalid hiccup in emit#37

Open
escherize wants to merge 1 commit intomasterfrom
better-emit-error-messages
Open

Improve error messages for invalid hiccup in emit#37
escherize wants to merge 1 commit intomasterfrom
better-emit-error-messages

Conversation

@escherize
Copy link
Owner

Summary

  • Adds a :default emit method that catches any unexpected dispatch value with a descriptive error message, special-casing bare keywords with a "wrap it in a vector" suggestion
  • Validates component return values against the parser before emitting, so invalid hiccup from a component identifies the component function, its args, and what it returned
  • Previously both cases produced No method in multimethod 'emit' for dispatch value: null with no context

Test plan

  • All 34 existing tests pass (177 assertions, 0 failures)
  • New component-invalid-hiccup-error-test: verifies error message and ex-data for components returning invalid hiccup

Add a :default emit method that catches unexpected dispatch values
with a descriptive message (special-casing bare keywords with a
"wrap it in a vector" hint). Also validate component return values
against the parser before emitting, so invalid hiccup from a
component identifies the component and what it returned instead of
producing "No method in multimethod 'emit' for dispatch value: null".
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