File Coverage

blib/lib/CGI/Session/ErrorHandler.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition 7 10 70.0
subroutine 5 5 100.0
pod 2 2 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package CGI::Session::ErrorHandler;
2              
3             # $Id: ErrorHandler.pm 216 2005-09-01 10:52:26Z sherzodr $
4              
5 18     18   79 use strict;
  18         22  
  18         1256  
6             $CGI::Session::ErrorHandler::VERSION = "4.01";
7              
8             =pod
9              
10             =head1 NAME
11              
12             CGI::Session::ErrorHandler - error handling routines for CGI::Session
13              
14             =head1 SYNOPSIS
15              
16             require CGI::Session::ErrorHandler
17             @ISA = qw( CGI::Session::ErrorHandler );
18              
19             sub some_method {
20             my $self = shift;
21             unless ( $some_condition ) {
22             return $self->set_error("some_method(): \$some_condition isn't met");
23             }
24             }
25              
26             =head1 DESCRIPTION
27              
28             CGI::Session::ErrorHandler provides set_error() and errstr() methods for setting and accessing error messages from within CGI::Session's components. This method should be used by driver developers for providing CGI::Session-standard error handling routines for their code
29              
30             =head2 METHODS
31              
32             =over 4
33              
34             =item set_error($message)
35              
36             Implicitly defines $pkg_name::errstr and sets its value to $message. Return value is B undef.
37              
38             =cut
39              
40             sub set_error {
41 10     10 1 18 my $class = shift;
42 10   66     41 $class = ref($class) || $class;
43 18     18   89 no strict 'refs';
  18         27  
  18         1607  
44 10   50     30 ${ "$class\::errstr" } = $_[0] || "";
  10         43  
45 10         56 return;
46             }
47              
48             =item errstr()
49              
50             Returns whatever value was set by the most recent call to set_error(). If no message as has been set yet, the empty string is returned so the message can still concatenate without a warning.
51              
52             =back
53              
54             =cut
55              
56             *error = \&errstr;
57             sub errstr {
58 15     15 1 1110 my $class = shift;
59 15   66     73 $class = ref( $class ) || $class;
60              
61 18     18   91 no strict 'refs';
  18         25  
  18         1062  
62 15   100     20 return ${ "$class\::errstr" } || '';
63             }
64              
65             =head1 LICENSING
66              
67             For support and licensing information see L.
68              
69             =cut
70              
71             1;
72