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

Fixing a panic in load_data #1036

Merged
merged 1 commit into from
May 25, 2020
Merged

Conversation

stanistan
Copy link
Contributor

If there is no response from the server, load_data would panic with: response status.

This patch removes the expect in favor of an error message that we couldn't get a response from the server for a given url.

Before:

Building site...
-> Creating 7 pages (3 orphan), 7 sections, and processing 1 images
thread 'main' panicked at 'response status', components/templates/src/global_fns/load_data.rs:216:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

Error: Failed to render page '/Users/stanistan/dev/stanistan.com/content/invoice/01.md'
Reason: Failed to render 'invoice.html'
Reason: Could not get response status for url: http://localhost:3000/invoice/01

Following up, I started thinking about it would be great if the function called in the templates would -- by default -- have messages that told you that they failed. I'm playing around with automatically wrapping all the registered Terra functions with messages/context using Error::chain so that the above response would look more like:

Error: Failed to render page '/Users/stanistan/dev/stanistan.com/content/invoice/01.md'
Reason: Failed to render 'invoice.html'
Reason: Failed calling tera function 'load_data'
Reason: Could not get response status for url: http://localhost:3000/invoice/01

Are you interested in a PR for this?

If there is no response from the server, `load_data` would panic
with: `response status`.

This patch removes the `expect` in favor of an error message that we
couldn't get a response from the server for a given url.
@stanistan stanistan force-pushed the fix-get-url-status-panic branch from ad5bad3 to 5deba62 Compare May 24, 2020 20:14
@Keats Keats merged commit 8d32f8b into getzola:next May 25, 2020
@Keats
Copy link
Collaborator

Keats commented May 25, 2020

Thanks!

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