Rest/BaseException.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 37 CC 2 SCAR 11.5
CC
2
Cov
0%
__generateError
6.0
initialize
2.0
raise
2.0
CRAP 3.1
1 package Eixo::Rest::BaseException;
2  
3 use strict;
4 use Eixo::Base::Clase;
5  
6 has(
7 method => '',
8 reason => '',
9 args => [],
10 error => '',
11 error_details => '',
12 );
13  
14 sub initialize {
15 my ($self, %args) = @_;
16  
17 $self->method($args{method});
18 $self->reason($args{reason});
19  
20 chomp(@{$args{args}});
21 $self->args($args{args});
22  
23 $self->__generateError();
24  
25 $self;
26 }
27  
28  
29 sub raise {
30  
31 die($_[0]);
32 }
33  
34  
35 sub __generateError {
36  
37 my $self = $_[0];
38  
39 if($self->can($self->reason)){
40 my $f = $self->reason;
41 $self->$f();
42 }
43 else{
44 $self->error("Unknown error");
45 $self->error_details('Unknown error in method '.$self->method.' with reason '.$self->reason);
46 }
47  
48 }
49  
50 #
51 # common reasons
52 #
53  
54 sub PARAM_NEEDED {
55 my $self = $_[0];
56 $self->error("Param needed");
57 $self->error_details("Method ".$self->method. " needs ".$self->args->[0]);
58 }
59  
60 1;