summaryrefslogtreecommitdiffstats
path: root/lib/App/ArchLinux/PackagerTools
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-12-18 10:59:10 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-12-18 10:59:10 +0100
commitabed9b97b2f7ecf631a9564e04ad80a2da19f04e (patch)
treed1f588cd9ad1c4c76733594bcd3676f189cf18f3 /lib/App/ArchLinux/PackagerTools
parent62c9a7224b024a011b52aeb79cae196458fe3279 (diff)
downloadApp-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.pm9
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;
}