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

Cannot convert data to Rhai dynamic error #10

Open
technosophos opened this issue Jan 6, 2022 · 0 comments
Open

Cannot convert data to Rhai dynamic error #10

technosophos opened this issue Jan 6, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@technosophos
Copy link
Collaborator

technosophos commented Jan 6, 2022

When a runtime error occurs with Rhai, we almost always get the same largely uninformative error:

For example, say we have this content/borken.md:

title = "Example of broken page"
template = "borken" # <-- uses borken.hbs
date = "2021-12-23T17:05:19Z"
---

And this templates/borken.hbs:

{{ borken }} <-- invokes the `borken.rhai`

And this scripts/borken.rhai:

// Note that msg is undefined, but this will parse.
// So it will generate a runtime error instead of a parse error.
"hello " + msg;

The result of executing the above would yield:

Rendering "/content/borken.md": Template 'borken': Error rendering "borken" line 1, col 1: Cannot convert data to Rhai dynamic

I can't figure out how to get a better error message out of the Handlebars engine.

Note that a parse error is much easier to debug, and it would be nice to have something closer to this:

Script "/scripts/borken.rhai": ParseError(ParseError(MissingToken(")", "to close the arguments list of this function call 'f'"), 5:3))
@technosophos technosophos added the bug Something isn't working label Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant