t-rex-tileserver / t-rex

t-rex is a vector tile server specialized on publishing MVT tiles from your own data
https://t-rex.tileserver.ch/
MIT License
545 stars 68 forks source link

improve error message failing rendering config #220

Closed arbakker closed 3 years ago

arbakker commented 3 years ago

T-rex outputs a generic error message when the rendering of the configuration file fails. A typical error message is for instance:

2020-12-16 20:05:29.607 INFO Reading configuration from '/home/anton/workspace/t-rex/tera.toml'
Error reading configuration - Template error: Failed to render '/home/anton/workspace/t-rex/tera.toml' 

With this fix t-rex outputs the errors from the Tera library, when the rendering fails. See for instance:

2020-12-16 20:13:26.575 INFO Reading configuration from '/home/anton/workspace/t-rex/tera.toml'
Error reading configuration - Template error: Variable `env.SPECIES` not found in context while rendering '/home/anton/workspace/t-rex/tera.toml'
pka commented 3 years ago

Thanks for the PR! Could you please also adapt the failing test:

---- core::config_test::test_tera_error stdout ----

thread 'core::config_test::test_tera_error' panicked at 'assertion failed: `(left == right)`

  left: `Some("Template error: Variable `env[\'UNDEFINED\']` not found in context while rendering \'inline.toml.tera\': the evaluated version was `env.UNDEFINED`. Maybe the index is out of bounds?")`,

 right: `Some("Template error: Failed to render \'inline.toml.tera\'")`', t-rex-core/src/core/config_test.rs:98:5

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
arbakker commented 3 years ago

Sure! I missed the failing test 🤦 . I also changed the test case slightly, I assumed the env['UNDEFINED'] notation was from an earlier Tera version.

pka commented 3 years ago

Nice to see the new CI tests running on a PR for the first time :-) Could you remove the .vscode files from the PR though?

arbakker commented 3 years ago

Off course, I just removed the vs code files from the PR. Didn't mean to do commit those... Should I squash the commits in this PR, so not to pollute the commit history with this?

p.s. I see the CI test failing, but failing test is not related to the PR. Any idea why the tests are failing?

pka commented 3 years ago

Please squash the commits to a single one.

I'm currently working on the CI in an other branch. The test seems to have been interrupted by other workflows.

arbakker commented 3 years ago

Thanks for merging!