X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FError.pm;h=d12d0806588e35ae67bddfe1148847fc504055c8;hb=37b09e0f2832514b33de4499a83f22d5ffe7c0a3;hp=7f44942caaee88e9a16acd9e72e6399bcb6422be;hpb=eb5adf956fc6b9285b43ce6965eea728573e7864;p=chaz%2Fp5-File-KDBX diff --git a/lib/File/KDBX/Error.pm b/lib/File/KDBX/Error.pm index 7f44942..d12d080 100644 --- a/lib/File/KDBX/Error.pm +++ b/lib/File/KDBX/Error.pm @@ -39,7 +39,7 @@ sub new { my $error = delete $args{_error}; my $e = $error; - # $e =~ s/ at \H+ line \d+.*//g; + $e =~ s/ at \H+ line \d+.*//g; my $self = bless { details => \%args, @@ -108,13 +108,30 @@ sub details { return $details; } -sub errno { $_[0]->{errno} } +=attr errno -sub previous { $_[0]->{previous} } +Get the value of C when the exception was created. + +=attr previous + +Get the value of C<$@> (i.e. latest exception) at the time the exception was created. + +=attr trace + +Get a stack trace indicating where in the code the exception was created. + +=cut -sub trace { $_[0]->{trace} // [] } +=attr type -sub type { $_[0]->details->{type} // '' } +Get the exception type, if any. + +=cut + +sub errno { $_[0]->{errno} } +sub previous { $_[0]->{previous} } +sub trace { $_[0]->{trace} // [] } +sub type { $_[0]->details->{type} // '' } =method to_string @@ -130,16 +147,10 @@ variable to truthy to stringify the whole error object. sub _cmp { "$_[0]" cmp "$_[1]" } -sub PROPAGATE { - 'wat'; -} - sub to_string { my $self = shift; - # return "uh oh\n"; my $msg = "$self->{trace}[0]"; - $msg .= '.' if $msg !~ /[\.\!\?]$/; # Why does this cause infinite recursion on some perls? - # $msg .= '.' if $msg !~ /(?:\.|!|\?)$/; + $msg .= '.' if $msg !~ /[\.\!\?]$/; if ($ENV{DEBUG}) { require Data::Dumper; local $Data::Dumper::Indent = 1;