File Coverage

blib/lib/Geoffrey/Exception/General.pm
Criterion Covered Total %
statement 31 35 88.5
branch 2 4 50.0
condition 3 6 50.0
subroutine 11 11 100.0
pod 5 5 100.0
total 52 61 85.2


line stmt bran cond sub pod time code
1             package Geoffrey::Exception::General;
2              
3 8     8   57 use utf8;
  8         17  
  8         49  
4 8     8   376 use 5.016;
  8         30  
5 8     8   43 use strict;
  8         24  
  8         218  
6 8     8   41 use warnings;
  8         14  
  8         252  
7 8     8   41 use Carp qw/longmess/;
  8         18  
  8         908  
8              
9             $Geoffrey::Exception::General::VERSION = '0.000204';
10              
11             use Exception::Class 1.23 (
12 8         106 'Geoffrey::Exception::General' => { description => 'Unidentified exception', },
13             'Geoffrey::Exception::General::TableNameMissing' => { description => 'No default value set for column in table!', },
14             'Geoffrey::Exception::General::UnknownAction' => { description => 'No default value set for column in table!', },
15             'Geoffrey::Exception::General::ParamsMissing' => { description => 'The sub needs some params!', },
16             'Geoffrey::Exception::General::WrongRef' => { description => 'The sub needs a ref!', },
17             'Geoffrey::Exception::General::Eval' => { description => 'Eval exception!', },
18              
19 8     8   71 );
  8         210  
20              
21             sub throw_wrong_ref {
22 8     8 1 24 my ( $s_sub, $s_type ) = @_;
23 8         108 return Geoffrey::Exception::General::WrongRef->throw( "$s_sub needs a $s_type\n" . longmess );
24             }
25              
26             sub throw_no_table_name {
27 4     4 1 10 my ($s_throw_message) = @_;
28 4         52 return Geoffrey::Exception::General::TableNameMissing->throw(
29             "I can't guess the table $s_throw_message\n" . longmess );
30             }
31              
32             sub throw_unknown_action {
33 4   50 4 1 16 my $s_throw_message = shift // q//;
34 4         44 return Geoffrey::Exception::General::UnknownAction->throw(
35             "Key for action $s_throw_message not found or implemented.\n Probaply misspelled.\n" . longmess );
36             }
37              
38             sub throw_no_params {
39 1   50 1 1 11 my $s_throw_message = shift // q//;
40 1         3 my $s_param = shift;
41 1         2 my $hr_params = shift;
42 1 50       5 if ($s_param) {
43 0         0 return Geoffrey::Exception::General::ParamsMissing->throw(
44             qq~The sub "$s_throw_message" needs param: '$s_param'\n~ . longmess );
45             }
46 1 50       4 if ($hr_params) {
47 0         0 require Data::Dumper;
48 0         0 my $s_params = Data::Dumper->new( [$hr_params] )->Terse(1)->Deparse(1)->Sortkeys(1)->Dump;
49 0         0 return Geoffrey::Exception::General::ParamsMissing->throw(
50             qq~The sub "$s_throw_message" needs param: '$s_param'!\n$s_params\n~ . longmess );
51             }
52 1         20 return Geoffrey::Exception::General::ParamsMissing->throw(
53             qq~The sub "$s_throw_message" needs some params.\n~ . longmess );
54             }
55              
56             sub throw_eval {
57 2   50 2 1 9 my $s_throw_message = shift // q//;
58 2         36 return Geoffrey::Exception::General::Eval->throw( qq~Eval exception with $s_throw_message.\n~ . longmess );
59             }
60              
61             1;
62              
63             __END__