SAJAX/Exception.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 60 CC 3 SCAR 15.0
CC
3
Cov
0%
throw
12.0
stringify
2.0
BEGIN
2.0
CRAP 4.5
1 package Net::SAJAX::Exception;
2  
3 use 5.008003;
4 use strict;
5 use warnings 'all';
6  
7 ###############################################################################
8 # METADATA
9 our $AUTHORITY = 'cpan:DOUGDUDE';
10 our $VERSION = '0.107';
11  
12 ###############################################################################
13 # MOOSE
14 use Moose 0.77;
15 use MooseX::StrictConstructor 0.08;
16  
17 ###############################################################################
18 # MODULE IMPORTS
19 use Carp qw(croak);
20 use Class::Load qw(load_class);
21  
22 ###############################################################################
23 # ALL IMPORTS BEFORE THIS WILL BE ERASED
24 use namespace::clean 0.04 -except => [qw(meta)];
25  
26 ###############################################################################
27 # OVERLOADED FUNCTIONS
28 __PACKAGE__->meta->add_package_symbol(q{&()} => sub { });
29 __PACKAGE__->meta->add_package_symbol(q{&(""} => sub { shift->stringify });
30  
31 ###############################################################################
32 # ATTRIBUTES
33 has message => (
34 is => 'ro',
35 isa => 'Str',
36 documentation => q{The error message},
37 required => 1,
38 );
39  
40 ###############################################################################
41 # METHODS
42 sub stringify {
43 my ($self) = @_;
44  
45 # The default stringify method just returns the contents of the message
46 # attribute.
47 return $self->message;
48 }
49 sub throw {
50 my ($class, %args) = @_;
51  
52 if (blessed $class) {
53 # Since $class is blessed, this was probably called as a method, so
54 # make $class the class name.
55 $class = blessed $class;
56 }
57  
58 my $exception_class = delete $args{class};
59  
60 if (!defined $exception_class) {
61 croak $class->new(%args);
62 }
63  
64 # Prefix this class to the beginning of the exception class
65 $exception_class = sprintf '%s::%s', $class, $exception_class;
66  
67 # Load the exception class
68 load_class($exception_class);
69  
70 croak $exception_class->new(%args);
71 }
72  
73 ###############################################################################
74 # MAKE MOOSE OBJECT IMMUTABLE
75 __PACKAGE__->meta->make_immutable;
76  
77 1;
78  
79 __END__