Silki/Exceptions.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 53 CC 3 SCAR 16.7
CC
3
Cov
0%
full_message
12.0
BEGIN
2.0
messages
2.0
CRAP 5.3
1 package Silki::Exceptions;
2 {
3 $Silki::Exceptions::VERSION = '0.29';
4 }
5  
6 use strict;
7 use warnings;
8  
9 my %E;
10  
11 BEGIN {
12 %E = (
13 'Silki::Exception' => {
14 alias => 'error',
15 description => 'Generic super-class for Silki exceptions'
16 },
17  
18 'Silki::Exception::DataValidation' => {
19 isa => 'Silki::Exception',
20 alias => 'data_validation_error',
21 fields => ['errors'],
22 description => 'Invalid data given to a method/function'
23 },
24 );
25 }
26  
27 {
28  
29 package Silki::Exception::DataValidation;
30 {
31 $Silki::Exception::DataValidation::VERSION = '0.29';
32 }
33  
34 sub messages { @{ $_[0]->errors || [] } }
35  
36 sub full_message {
37 if ( my @m = $_[0]->messages ) {
38 return join "\n", 'Data validation errors: ',
39 map { ref $_ ? $_->{message} : $_ } @m;
40 }
41 else {
42 return $_[0]->SUPER::full_message();
43 }
44 }
45 }
46  
47 use Exception::Class (%E);
48  
49 Silki::Exception->Trace(1);
50  
51 use Exporter qw( import );
52  
53 our @EXPORT_OK = map { $_->{alias} || () } values %E;
54  
55 1;
56  
57 # ABSTRACT: Exception classes used by Silki
58  
59 __END__