diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-12-18 10:59:10 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-18 10:59:10 +0100 |
commit | abed9b97b2f7ecf631a9564e04ad80a2da19f04e (patch) | |
tree | d1f588cd9ad1c4c76733594bcd3676f189cf18f3 /lib/App/ArchLinux/PackagerTools | |
parent | 62c9a7224b024a011b52aeb79cae196458fe3279 (diff) | |
download | App-ArchLinux-PackagerTools-abed9b97b2f7ecf631a9564e04ad80a2da19f04e.tar.gz App-ArchLinux-PackagerTools-abed9b97b2f7ecf631a9564e04ad80a2da19f04e.tar.xz |
Config: Fix config file parsing and parser error handling
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/ArchLinux/PackagerTools')
-rw-r--r-- | lib/App/ArchLinux/PackagerTools/Config.pm | 9 |
1 files 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; } |