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

More friendly PageFrontMatter deserialize error messages #1313

Closed
wdv4758h opened this issue Jan 16, 2021 · 6 comments
Closed

More friendly PageFrontMatter deserialize error messages #1313

wdv4758h opened this issue Jan 16, 2021 · 6 comments
Labels
done in pr Already done in a PR enhancement

Comments

@wdv4758h
Copy link
Contributor

Bug Report

Environment

Zola version: 0.13.0

Expected Behavior

With some bad metdata for the page, we will get panic messages when doing deserialize for PageFrontMatter. The messages are kind of helpful but not in a way that's friendly.

It will be great to have some suggestion like the Rust compiler has.
Like:

--> file.md:2:9
  |
1 | +++
2 | draft = ture
  |         ^^^^ help: this could be a typo, a similar value exists: `true`

This might be a fair amount of work, but I think friendly error messages is valuable. It will be good to in the roadmap.

Current Behavior

For example, the draft field should be bool, but if you somehow have typo that having draft = ture in the file. Then you will get messages like:

thread 'main' panicked at 'error deserialising page: Error { kind: Msg("Error when parsing front matter of page `/path/to/that/file.md`"), source: Some(Error { kind: Toml(Error { inner: ErrorInner { kind: UnquotedString, line: Some(1), col: 8, at: Some(9), message: "", key: [] } }), source: None }) }', components/site/src/lib.rs:264:22

It does tell which file has the problem, but the error messages say UnquotedString.

Step to reproduce

  1. write draft = ture instead of draft = true to a page
  2. ask zola to build it

Still wanna say thank you, I enjoy using Zola :)

@Keats Keats added the bug label Jan 17, 2021
@Keats
Copy link
Collaborator

Keats commented Jan 17, 2021

Hmm it shouldn't be a panic but we're depending on toml-rs error handling there.

@Keats
Copy link
Collaborator

Keats commented Feb 2, 2021

The panic is fixed but the error message I'm not too sure.

@wdv4758h
Copy link
Contributor Author

wdv4758h commented Feb 6, 2021

I think that will be good enough for now :)

@wdv4758h
Copy link
Contributor Author

wdv4758h commented Jun 2, 2021

I just see this library. It seems related to friendly error messages.
https://github.com/AlexanderThaller/format_serde_error

pic

@Keats
Copy link
Collaborator

Keats commented Jun 2, 2021

Oooh that's nice. It seems a bit early to use it but it's promising

@wdv4758h
Copy link
Contributor Author

wdv4758h commented Jun 2, 2021

agree, that's wait and see :)

@Keats Keats added enhancement and removed bug labels Jan 20, 2023
@Keats Keats added the done in pr Already done in a PR label Jan 27, 2023
Keats added a commit that referenced this issue Feb 8, 2023
@Keats Keats closed this as completed in 4cd80a3 Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done in pr Already done in a PR enhancement
Projects
None yet
Development

No branches or pull requests

2 participants