Crypt/Error.pm

filter: Statementstmt 54.5% 12 / 22 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 45.2% 19 / 42 CC 6 SCAR 23.2
CC
6
Cov
38%
error
20.0
set_error
12.0
new
2.0
CRAP 10.2
« Crypt/Msg.pm ↑ Summary Crypt.pm »
1 # FTN::Crypt::Error - Error processing for the FTN::Crypt module
2 #
3 # Copyright (C) 2019 by Petr Antonov
4 #
5 # This library is free software; you can redistribute it and/or modify it
6 # under the same terms as Perl 5.10.0. For more details, see the full text
7 # of the licenses at https://opensource.org/licenses/Artistic-1.0, and
8 # http://www.gnu.org/licenses/gpl-2.0.html.
9 #
10 # This package is provided "as is" and without any express or implied
11 # warranties, including, without limitation, the implied warranties of
12 # merchantability and fitness for a particular purpose.
13 #
14  
15 package FTN::Crypt::Error;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #----------------------------------------------------------------------#
22  
23 =head1 NAME
24  
25 FTN::Crypt::Error - Error processing for the L<FTN::Crypt> module.
26  
27 =head1 SYNOPSIS
28  
29 Inherit your class from FTN::Crypt::Error. Then, to set error message:
30  
31 Class->set_error($message)
32 $obj->set_error($message)
33  
34 To get error message:
35  
36 Class->error
37 $obj->error
38  
39 =cut
40  
41 #----------------------------------------------------------------------#
42  
43 1 ▶use vars qw/$_ERROR_/;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 #----------------------------------------------------------------------#
46  
47 =head2 new()
48  
49 Constructor.
50  
51 =head3 Parameters:
52  
53 None.
54  
55 =head3 Returns:
56  
57 Created object.
58  
59 =cut
60  
61 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
62 0 return bless {
63 _ERROR_ => '',
64 }, shift;
65 }
66  
67 #----------------------------------------------------------------------#
68  
69 =head2 set_error()
70  
71 Set error message.
72  
73 =head3 Parameters:
74  
75 =over 4
76  
77 =item * Error message.
78  
79 =back
80  
81 =head3 Returns:
82  
83 None.
84  
85 =cut
86  
87 0 ▶sub set_error {
Subroutine set_error: not called CC=3 SCAR=24.8
Pod documented
88 0 my $self = shift;
89  
90 0 ▶ my $errstr = ref($_[0]) ? shift : join("\n", @_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
91 0 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
92 0 $self->{_ERROR_} = $errstr;
93 } else {
94 0 $_ERROR_ = $errstr;
95 }
96 }
97  
98 #----------------------------------------------------------------------#
99  
100 =head2 error()
101  
102 Get error message.
103  
104 =head3 Parameters:
105  
106 None.
107  
108 =head3 Returns:
109  
110 Error message.
111  
112 =cut
113  
114 0 ▶sub error {
Subroutine error: not called CC=4 SCAR=30.0
Pod documented
115 0 my $self = shift;
116  
117 0 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
118 0 ▶ return defined $self->{_ERROR_} ? $self->{_ERROR_} : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_ERROR_'} ? : 0 0 0
119 } else {
120 0 ▶ return defined $_ERROR_ ? $_ERROR_ : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $FTN::Crypt::Error::_ERROR_ ? : 0 0 0
121 }
122 }
123  
124 1 1;
125 __END__
« Crypt/Msg.pm ↑ Summary Crypt.pm »