diff --git a/bin/access-check-manager.pl b/bin/access-check-manager.pl
index cbeb419df2e1a209ea2e0c3baad02a4c9ec7768c..16018d5cac26addccce2b30f0860082f42660563 100755
--- a/bin/access-check-manager.pl
+++ b/bin/access-check-manager.pl
@@ -13,6 +13,7 @@ use DateTime;
 use English qw(-no_match_vars);
 use Getopt::Long qw(:config auto_help);
 use Pod::Usage;
+use Syntax::Keyword::Try;
 
 use AccountManager::Data::Account;
 use AccountManager::Data::Entity;
@@ -151,15 +152,15 @@ sub list_accounts {
             db => $db
         );
 
-        eval {
+        try {
             AccountManager::Tools::update_ssp_authsources(
                 $configuration->{setup}->{templates_dir},
                 $configuration->{setup}->{accounts_file},
                 $accounts
             );
-        };
-        die "failed to update simpleSAMLphp configuration file: $EVAL_ERROR"
-            if $EVAL_ERROR;
+        } catch ($error) {
+            die "failed to update simpleSAMLphp configuration file: $error"
+        }
 
         printf "Update simpleSamlPhp configuration file...\n";
     }
@@ -169,12 +170,13 @@ sub list_accounts {
 sub parse_metadata {
     my $federation_metadata;
 
-    eval {
+    try {
         $federation_metadata = AccountManager::Metadata->new(
             file => $configuration->{setup}->{federation_metadata_file}
         );
-    };
-    die "unable to load federation metadata: $EVAL_ERROR" if $EVAL_ERROR;
+    } catch ($error) {
+        die "unable to load federation metadata: $error";
+    }
 
     my $data = $federation_metadata->parse(id => $options{entityid});
 
diff --git a/bin/update-metadata b/bin/update-metadata
index 7ae0e590830916b7c69b1e5b804025172695e16e..37e79ccfc7d942dcf0af4435ba5a26426bdf5314 100755
--- a/bin/update-metadata
+++ b/bin/update-metadata
@@ -13,6 +13,7 @@ use Getopt::Long qw(:config auto_help);
 use List::MoreUtils qw(uniq);
 use Mojo::UserAgent;
 use Pod::Usage;
+use Syntax::Keyword::Try;
 
 use AccountManager::Data::DB;
 use AccountManager::Data::Entity;
@@ -82,24 +83,22 @@ foreach my $id (keys %{$configuration->{federations}}) {
     $result->save_to($file->filename());
 
     my $metadata;
-    eval {
+    try {
         $metadata = AccountManager::Metadata->new(
             file => $file
         );
-    };
-    if ($EVAL_ERROR) {
+    } catch ($error) {
         $db->rollback();
-        die "failed to load federation metadata: $EVAL_ERROR";
+        die "failed to load federation metadata: $error";
     }
 
     print "parsing metadata from file $file\n" if $options{verbose};
     my $entities;
-    eval {
+    try {
        $entities = $metadata->parse();
-    };
-    if ($EVAL_ERROR) {
+    } catch ($error) {
         $db->rollback();
-        die "failed to parse federation metadata: $EVAL_ERROR";
+        die "failed to parse federation metadata: $error";
     }
 
     foreach my $entry (@$entities) {
@@ -118,28 +117,28 @@ foreach my $id (keys %{$configuration->{federations}}) {
             );
             $entity->update();
         } else {
-            eval {
-                $entity = AccountManager::Data::Entity->new(
-                    db               => $db,
-                    type             => $entry->{type},
-                    entityid         => $entry->{entityid},
-                    display_name     => $entry->{display_name},
-                    information_url  => $entry->{information_url},
-                    organization_url => $entry->{organization_url},
-                );
-                if ($entry->{contacts}) {
-                    my @contacts =
-                    uniq
-                    grep { $_ }
-                    map { $_->{EmailAddress} }
-                    @{$entry->{contacts}};
-                    $entity->contacts(@contacts);
-                }
-                $entity->federations($id);
+            $entity = AccountManager::Data::Entity->new(
+                db               => $db,
+                type             => $entry->{type},
+                entityid         => $entry->{entityid},
+                display_name     => $entry->{display_name},
+                information_url  => $entry->{information_url},
+                organization_url => $entry->{organization_url},
+            );
+            if ($entry->{contacts}) {
+                my @contacts =
+                uniq
+                grep { $_ }
+                map { $_->{EmailAddress} }
+                @{$entry->{contacts}};
+                $entity->contacts(@contacts);
+            }
+            $entity->federations($id);
+
+            try {
                 $entity->save();
-            };
-            if ($EVAL_ERROR) {
-                warn "error while processing entity $entry->{entityid}: $EVAL_ERROR";
+            } catch ($error) {
+                warn "error while processing entity $entry->{entityid}: $error";
             }
         }