From 88b2c65bf15734148cde7369d43a263eb77117f1 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sun, 14 Jul 2019 07:27:19 +0000 Subject: a bunch of changes, all related to error-handling: - have Handle->register also create a proper END block, so that individual packages don't have to, and explain the issue - kill old Unlink/Copy code that migrated to State years ago - commonalize try{} catch {} for pkg_add/delete and pkg_create, so that debug works the same way in both. - switch printing command name to the catch handler, so that exceptions are simpler to handle and a few comments for the hairy parts... --- usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepository.pm') diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index e19d2eceaa9..25bd6b9a401 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.164 2019/07/10 09:34:38 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.165 2019/07/14 07:27:18 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -82,18 +82,12 @@ sub unique return $o; } -my $cleanup = sub { +OpenBSD::Handler->register( + sub { for my $repo (values %$cache) { $repo->cleanup; } -}; -END { - my $a = $?; - &$cleanup; - $? = $a; -} - -OpenBSD::Handler->register($cleanup); + }); sub parse_fullurl { -- cgit v1.2.3