lib/CallBackery/Exception.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 91.8% 34 / 37 CC 1 SCAR 1.2
CC
1
Cov
93%
stringify
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Mojolicious/Command/generate/callbackery_app/lib/App/Controller/RpcService.pm ↑ Summary
1 package CallBackery::Exception;
2  
3 =head1 NAME
4  
5 CallBackery::Exception - a simple exception class
6  
7 =head1 SYNOPSIS
8  
9 use CallBackery::Exception qw(mkerror);
10  
11 eval { die error(22,'Bad Error'); }
12 if ($@){
13 print "Code: '.$@->code()." Message: ".$@->message()."\n"
14 print "$@\n"; #stringified error
15 }
16
17 =head1 DESCRIPTION
18  
19 An error object.
20  
21 Maybe use L<Mojo::Exception> instead.
22  
23 =over
24  
25 =cut
26  
27 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use vars qw(@EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 @EXPORT_OK = qw(mkerror);
33  
34 1 ▶use overload ('""' => 'stringify');
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36  
37 1 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 has 'code';
39 1 has 'message';
40  
41  
42  
43 =item B<mkerror>(I<code>,I<message>)
44  
45 Create an nq::Exception object, setting code and message properties in the process.
46  
47 =cut
48  
49 1 ▶sub mkerror {
Subroutine mkerror: called CC=1 SCAR=0.0
Pod documented
50 1 my $code = shift;
51 1 my $message = shift;
52 # use caller() to determin where this is happening
53 # somehow construct the error code from the line number ....??
54 1 return (__PACKAGE__->new(code=>$code,message=>$message));
55 }
56  
57 =item B<stringify>
58  
59 error stringification handler
60  
61 =cut
62  
63 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
64 0 my $self = shift;
65 0 return "ERROR ".$self->code().": ".$self->message()."\n";
66 }
67  
68 1 1;
69 __END__
« blib/lib/Mojolicious/Command/generate/callbackery_app/lib/App/Controller/RpcService.pm ↑ Summary