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

Improve error message by providing the file where the error occurred if it is not an inlined source #986

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

GuillaumeGomez
Copy link
Contributor

When you have templates included in templates, the errors become quite difficult to understand as we don't know which file is triggering it. With this change, it adds the path of the file where the error is located:

error: problems parsing template source in `templates/core/about/builds.html` at row 34, column 32 near:
       "=\"rust\") %}{% filter dedent(levels=3) -%"...
   --> src/web/sitemap.rs:109:10
    |
109 | #[derive(Template)]
    |          ^^^^^^^^
    |
    = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

Making my life and very likely everyone else's better. :)

Sadly, I can't enforce it with trybuild as it only allows to have inline tests (because the folder where the ui tests are run is different and I couldn't find a way to do it...).

askama_parser/src/lib.rs Outdated Show resolved Hide resolved
askama_derive/src/input.rs Outdated Show resolved Hide resolved
@GuillaumeGomez GuillaumeGomez force-pushed the improve-error branch 13 times, most recently from a85b30a to 7ae98b4 Compare March 12, 2024 13:29
@GuillaumeGomez
Copy link
Contributor Author

Finally made tests work on CI. \o/

I added a ui test as well (took me more time than I expected...).

@GuillaumeGomez GuillaumeGomez force-pushed the improve-error branch 2 times, most recently from e726b14 to d353041 Compare March 18, 2024 14:48
@GuillaumeGomez
Copy link
Contributor Author

Updated!

askama_derive/src/input.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Contributor Author

Rebased on #994.

testing/tests/ui.rs Outdated Show resolved Hide resolved
testing/tests/ui.rs Outdated Show resolved Hide resolved
testing/tests/ui.rs Outdated Show resolved Hide resolved
testing/tests/ui.rs Outdated Show resolved Hide resolved
askama_parser/src/lib.rs Outdated Show resolved Hide resolved
askama_parser/src/lib.rs Outdated Show resolved Hide resolved
askama_parser/src/lib.rs Show resolved Hide resolved
testing/tests/ui.rs Show resolved Hide resolved
askama_parser/src/lib.rs Show resolved Hide resolved
testing/tests/ui/error_file_path.stderr Show resolved Hide resolved
@GuillaumeGomez
Copy link
Contributor Author

Thanks for the reviews! Merging then. :)

@GuillaumeGomez GuillaumeGomez merged commit 45ae8da into djc:main Apr 5, 2024
16 checks passed
@GuillaumeGomez GuillaumeGomez deleted the improve-error branch April 5, 2024 10:13
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.

2 participants