Puzzle/Exception.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 37 CC 3 SCAR 19.5
CC
3
Cov
0%
raise
12.0
print
2.0
BEGIN
2.0
CRAP 7.0
1 package Puzzle::Exception;
2  
3 our $VERSION = '0.21';
4  
5 use base 'Class::Container';
6 use File::Spec;
7  
8 sub raise {
9 my $self = shift;
10 my $error_code = shift;
11  
12 my $tmpl = $self->container->tmpl;
13 my $mason = $self->container->_mason;
14  
15 # add original component yaml structures to add errors
16 my $comp_path = $mason->current_comp->source_file;
17  
18 my @dots = split(/\./,$comp_path);
19 $dots[-1] = 'yaml';
20 my $yaml_path = join('.',@dots);
21 if (-e $yaml_path) {
22 my $lang = $self->container->lang_manager->lang;
23 my $yaml_args = $tmpl->yamlArgs($yaml_path,$lang);
24 foreach (qw/cod descr linkback/) {
25 if (exists $yaml_args->{exception}->{$error_code}->{$_}) {
26 $self->container->args->set('exception.'. $_ =>
27 $yaml_args->{exception}->{$error_code}->{$_});
28 }
29 }
30 }
31  
32  
33 $self->container->args->set(errorcode => $error_code);
34 $self->print;
35 # usefull to return your function with 0 if errors
36 return 0;
37 }
38  
39 sub print {
40 my $self = shift;
41 my $error_path = $self->container->cfg->exception_file;
42 print $self->container->tmpl->html(undef,$error_path);
43  
44 }
45  
46 1;