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 handling and reporting #120

Merged
merged 1 commit into from
Aug 15, 2023
Merged

Improve error handling and reporting #120

merged 1 commit into from
Aug 15, 2023

Conversation

welpo
Copy link
Contributor

@welpo welpo commented Aug 15, 2023

Summary

The proposed changes introduce enhanced error handling mechanisms to the theme processing code. The revised script gathers errors during execution and provides a summarised report at the end.

Related issue: #119

Main Changes

  1. Centralized error collection: Introduces an errors list to gather all the issues detected during script execution.
  2. Graceful failure on TOML parsing: Previously, failing to parse a theme's TOML metadata would result in a crash. Now, it captures the error, logs it, and allows the script to continue processing other themes.
  3. Enhanced reporting: At the end of the script's run, all collected errors are displayed in a formatted manner, offering a clear view of issues to address.
  4. Script summary: After processing, the script provides a count of the total themes successfully processed and the number of themes with errors.

Example

Here's a sample of the new error summary:

============================================================
ERROR SUMMARY:
------------------------------------------------------------
Theme 'abc' is missing required metadata: name.
------------------------------------------------------------
Theme 'def' is missing screenshot.png.
------------------------------------------------------------
Theme 'ghi' is missing README.md.
------------------------------------------------------------
Theme 'jkl' encountered a TOML parsing issue: Duplicate keys! (line 5 column 1 char 121)
------------------------------------------------------------
============================================================


Themes successfully processed: 68
Themes with errors: 4

Benefits

  • Enhanced clarity: Problematic themes become instantly identifiable, minimising the chance of oversight.
  • Resilience: The script's enhanced error handling ensures that a single problematic theme.toml doesn't halt the entire process.

- Introduce a global 'errors' list to store
error messages encountered during execution.
- Enhance error checking for missing files and metadata,
adding detailed error messages to the global list.
- Modify the Theme class constructor to exit early
if there's an error while parsing the TOML file.
- Streamline error display at the end of execution with
a clear summary of successful and failed theme processing.
@Keats Keats merged commit 771f6af into getzola:master Aug 15, 2023
1 check passed
@Keats
Copy link
Collaborator

Keats commented Aug 15, 2023

Very nice, 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