From cfadf8415f8ffe74c0d1f8d890dc1c155cfecd4f Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Mon, 18 Apr 2022 18:29:38 -0600 Subject: [PATCH] Fix error wrapping --- lib/File/KDBX/Error.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/File/KDBX/Error.pm b/lib/File/KDBX/Error.pm index f801557..6ea0649 100644 --- a/lib/File/KDBX/Error.pm +++ b/lib/File/KDBX/Error.pm @@ -78,10 +78,11 @@ as a B. Example: =cut sub error { + my $class = @_ && $_[0] eq __PACKAGE__ ? shift : undef; my $self = (blessed($_[0]) && $_[0]->isa('File::KDBX::Error')) ? shift - : (@_ && $_[0] eq __PACKAGE__) - ? shift->new(@_) + : $class + ? $class->new(@_) : __PACKAGE__->new(@_); return $self; } -- 2.43.0