Skip to content
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

renderer: Helpful panic for unknown NodeKind #110

Closed
wants to merge 1 commit into from
Closed

renderer: Helpful panic for unknown NodeKind #110

wants to merge 1 commit into from

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Mar 7, 2020

(Follow up to #107.)

When rendering a Node, Renderer looks up the NodeRenderer for that
node's kind in a slice. That will panic with an "index out of range"
error if a node renderer for that node kind has not been registered.

panic: runtime error: index out of range [1] with length 1

This changes Renderer to panic with a more helpful error message if the
node kind is unrecognized.

panic: unrecognized node kind Document cannot be rendered:
register a renderer for this node kind first

When rendering a Node, Renderer looks up the NodeRenderer for that
node's kind in a slice. That will panic with an "index out of range"
error if a node renderer for that node kind has not been registered.

    panic: runtime error: index out of range [1] with length 1

This changes Renderer to panic with a more helpful error message if the
node kind is unrecognized.

    panic: unrecognized node kind Document cannot be rendered:
    register a renderer for this node kind first
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.

None yet

1 participant