line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Error::Dumb; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
714
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Error::Dumb - simple error management for simple classes |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Some::Simple::Class; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $Obj = new Some::Simple::Class; |
14
|
|
|
|
|
|
|
$Obj->doSomething() or die $Obj->error(): |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Some::Simple::Class; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Error::Dumb; |
20
|
|
|
|
|
|
|
use vars qw(@ISA); |
21
|
|
|
|
|
|
|
# inherit from Error::Dumb |
22
|
|
|
|
|
|
|
@ISA = qw(Error::Dumb); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub doSomething { |
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
return $self->_setError('oops, failed to do something'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Error::Dumb is a base class that is meant to be inherited by other classes. |
32
|
|
|
|
|
|
|
All this class provides is an interface for setting and retrieving error messages; as documented below... |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 INTERFACE |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 error |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Accessor for private scalar ERROR. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
229
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$VERSION = do { my @r=(q$Revision: 1.2 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub error { |
47
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self->{ERROR}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 err |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Alias to error() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub err { |
59
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->error(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 _setError(ERRMSG) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Set private scalar ERROR to ERRMSG. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _setError { |
71
|
0
|
|
|
0
|
|
|
my ($self, $errmsg) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->{ERROR} = $errmsg; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return undef; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |