| 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
| |||||||||||
| 91 | 0 | ▶ | if (ref($self)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 118 | 0 | ▶ | return defined $self->{_ERROR_} ? $self->{_ERROR_} : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | } else { | ||||||||||
| 120 | 0 | ▶ | return defined $_ERROR_ ? $_ERROR_ : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | } | ||||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | 1 | 1; | |||||||||
| 125 | __END__ | ||||||||||