| 1 | package Error::Dumb; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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 | ▶ | use vars qw($VERSION); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 43 | |||
| 44 | 1 | $VERSION = do { my @r=(q$Revision: 1.2 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; | |
| 45 | |||
| 46 | 0 | ▶ | sub error { |
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 47 | 0 | my ($self) = @_; | |
| 48 | |||
| 49 | 0 | return $self->{ERROR}; | |
| 50 | } | ||
| 51 | |||
| 52 | =head2 err | ||
| 53 | |||
| 54 | Alias to error() | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | 0 | ▶ | sub err { |
|
Subroutine
err: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 59 | 0 | 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 | 0 | ▶ | sub _setError { |
|
Subroutine
_setError: not called CC=1 SCAR=6.9
| |||
| 71 | 0 | my ($self, $errmsg) = @_; | |
| 72 | |||
| 73 | 0 | $self->{ERROR} = $errmsg; | |
| 74 | |||
| 75 | 0 | return undef; | |
| 76 | } | ||
| 77 | |||
| 78 | 1 | 1; | |
| 79 | |||
| 80 | __END__ | ||