From abed9b97b2f7ecf631a9564e04ad80a2da19f04e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 18 Dec 2018 10:59:10 +0100 Subject: Config: Fix config file parsing and parser error handling Signed-off-by: Florian Pritz --- lib/App/ArchLinux/PackagerTools/Config.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/App/ArchLinux/PackagerTools/Config.pm b/lib/App/ArchLinux/PackagerTools/Config.pm index 4477053..bd8dfc1 100644 --- a/lib/App/ArchLinux/PackagerTools/Config.pm +++ b/lib/App/ArchLinux/PackagerTools/Config.pm @@ -4,7 +4,7 @@ use strictures; use autodie; use Function::Parameters; use Log::Any qw($log); -use Hash::Merge; +use Hash::Merge qw(merge); use Path::Tiny; use TOML qw(from_toml); @@ -81,12 +81,15 @@ method _load_config() { my $file = path(($ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config")."/perlpkg/config.toml"); if ($file->exists) { $log->debugf("Reading config file: %s", $file); - my $file_config = from_toml($file->slurp); + my ($file_config, $err) = from_toml($file->slurp); + die $log->errorf("Failed to parse config file: %s", $err) unless $file_config; + $log->debugf("config = %s", $config); + $log->debugf("file_config = %s", $file_config); $config = merge($file_config, $config); - } else { $log->debug("Config file not found. Returning default config"); } + $log->debugf("Loaded configuration is: %s", $config); return $config; } -- cgit v1.2.3-24-g4f1b