From 1737cbac3e0aea0d361b5c051bd3aca4d1db74cc Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Tue, 1 Feb 2022 16:37:25 +0100 Subject: [PATCH] switch to Syntax::Keyword::Try --- lib/AccountManager/Metadata.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/AccountManager/Metadata.pm b/lib/AccountManager/Metadata.pm index f5d6a67..6be1138 100644 --- a/lib/AccountManager/Metadata.pm +++ b/lib/AccountManager/Metadata.pm @@ -3,6 +3,7 @@ package AccountManager::Metadata; use Mojo::Base -base; use English qw(-no_match_vars); +use Syntax::Keyword::Try; use XML::LibXML qw(:libxml); sub new { @@ -13,8 +14,11 @@ sub new { die "non-readable file $args{file}" unless -r $args{file}; my $doc; - eval { $doc = XML::LibXML->load_xml(location => $args{file}); }; - die "Failed to parse file: $EVAL_ERROR" if $EVAL_ERROR; + try { + $doc = XML::LibXML->load_xml(location => $args{file}); + } catch($error) { + die "Failed to parse file: $error"; + } my $root = $doc->documentElement(); my $type = $root->nodeName(); -- GitLab