Client/ErrorHandler.pm

filter: Statementstmt 50.0% 5 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 1 / 3 Podpod 100% 2 / 2 totaltotal 53.3% 8 / 15 CC 1 SCAR 5.1
CC
1
Cov
50%
ERROR
2.0
errstr
2.0
BEGIN
1.0
CRAP 1.7
« Client/Request.pm ↑ Summary Client/Agent/Dump.pm »
1 package Net::OpenSocial::Client::ErrorHandler;
2  
3 1 ▶use Any::Moose '::Role';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 has '_errstr' => (
6 is => 'rw',
7 isa => 'Str',
8 );
9  
10 0 ▶sub ERROR {
Subroutine ERROR: not called CC=1 SCAR=6.9
Pod documented
11 0 my ( $self, $message ) = @_;
12 0 $self->_errstr($message);
13 0 return;
14 }
15  
16 0 ▶sub errstr {
Subroutine errstr: not called CC=1 SCAR=6.9
Pod documented
17 0 my $self = shift;
18 0 return $self->_errstr;
19 }
20  
21 1 1;
22  
23 =head1 NAME
24  
25 Net::OpenSocial::Client::ErrorHandler - Error handler role
26  
27 =head1 SYNOPSIS
28  
29 package MyClass;
30 use Any::Moose;
31 with 'Net::OpenSocial::Client::ErrorHandler';
32 sub my_method {
33 my $self = shift;
34 if ( $self->found_any_error ) {
35 return $self->ERROR('Error occured.');
36 }
37 return 1;
38 }
39  
40 package main;
41 use MyClass;
42 my $foo = MyClass->new;
43 my $result = $foo->my_method
44 or die $foo->errstr;
45  
46 =head1 DESCRIPTION
47  
48 Error handler role.
49 This provides a simple way to handle error.
50  
51 =head1 METHODS
52  
53 =head2 ERROR( $message )
54  
55 When some error occured, call like that
56  
57 return $self->ERROR($error_message);
58  
59 And this returns undef.
60 After that, you can pick up the error message by calling 'errstr' method.
61  
62 =head2 errstr
63  
64 If it already called 'ERROR' method, it returns an error message.
65  
66 die $self->errstr;
67  
68 =head1 SEE ALSO
69  
70 L<Class::ErrorHandler>
71  
72 =head1 AUTHOR
73  
74 Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
75  
76 =head1 COPYRIGHT AND LICENSE
77  
78 Copyright (C) 2009 by Lyo Kato
79  
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself, either Perl version 5.8.8 or,
82 at your option, any later version of Perl 5 you may have available.
83  
84 =cut
85  
« Client/Request.pm ↑ Summary Client/Agent/Dump.pm »