blib/lib/Crypt/OpenPGP/ErrorHandler.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 11 | 14 | 78.5 |
branch | 2 | 6 | 33.3 |
condition | n/a | ||
subroutine | 3 | 5 | 60.0 |
pod | 2 | 3 | 66.6 |
total | 18 | 28 | 64.2 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Crypt::OpenPGP::ErrorHandler; | ||||||
2 | 2 | 2 | 11 | use strict; | |||
2 | 3 | ||||||
2 | 77 | ||||||
3 | |||||||
4 | 2 | 2 | 11 | use vars qw( $ERROR ); | |||
2 | 4 | ||||||
2 | 471 | ||||||
5 | |||||||
6 | 0 | 0 | 0 | 0 | sub new { bless {}, shift } | ||
7 | sub error { | ||||||
8 | 6 | 6 | 1 | 9 | my $msg = $_[1]; | ||
9 | 6 | 50 | 17 | $msg .= "\n" unless $msg =~ /\n$/; | |||
10 | 6 | 50 | 13 | if (ref($_[0])) { | |||
11 | 0 | 0 | $_[0]->{_errstr} = $msg; | ||||
12 | } else { | ||||||
13 | 6 | 8 | $ERROR = $msg; | ||||
14 | } | ||||||
15 | 6 | 79 | return; | ||||
16 | } | ||||||
17 | 0 | 0 | 0 | 1 | sub errstr { ref($_[0]) ? $_[0]->{_errstr} : $ERROR } | ||
18 | |||||||
19 | 1; | ||||||
20 | __END__ |