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 for loading config file #101

Draft
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

ivinjabraham
Copy link

@ivinjabraham ivinjabraham commented Feb 15, 2025

Prerequisite

This change assume we can change App::new() to initialize logging earlier, since currently it is only initialized after Config is built as seen here:

    pub fn new() -> App {
        let config: Config = Config::build();
        config.create_dirs();

        ...

        // Initialize the logger before the app starts
        Logger::init_log_file(&config);
        Logger::info("patch-hub started");
        logging::garbage_collector::collect_garbage(&config);

And it seems #99 should allow us to do so.

Overview of changes

Previously, errors when failing to read or parse the config. file were not logged. Errors in failing to read was also silently mitigated by defaulting to an empty string, which could lead to more problems down the road.

Users are still not notified directly (they will have to check the logs) when this happens, and I think that might be necessary?

Add detailed error logging when reading and parsing configuration files to help
diagnose configuration issues. Previously, file read errors were silently
converted to empty strings, which could lead to confusing JSON parse errors
without indicating the root cause.
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.

1 participant