blib/lib/Config/Model/Exception.pm

filter: Statementstmt 83.8% 250 / 298 Branchbran 52.9% 36 / 68 Conditioncond 40.7% 11 / 27 MC/DCmcdc 6.6% 1 / 15 Subroutinesub 81.0% 60 / 74 Podpod 5.2% 1 / 19 totaltotal 71.6% 359 / 501 CC 46 SCAR 20.5
CC
46
Cov
76%
full_message
35.5
full_message
20.0
full_message
12.0
CRAP 7.8
« blib/lib/Config/Model/Role/ComputeFunction.pm ↑ Summary blib/lib/Config/Model/AnyThing.pm »
1 #
2 # This file is part of Config-Model
3 #
4 # This software is Copyright (c) 2005-2022 by Dominique Dumont.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package Config::Model::Exception 2.169;
11  
12 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 59 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 59 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 59 ▶use feature qw/postderef signatures/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 59 ▶no warnings qw/experimental::postderef experimental::signatures/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # I don't like multiple packages in a file, but this is an Exception
23 ## no critic (Modules::ProhibitMultiplePackages)
24  
25 59 @Carp::CARP_NOT=qw/Config::Model::Exception Config::Model::Exception::Any/;
26  
27 59 our $trace = 0;
28  
29 59 ▶use Carp qw/longmess shortmess croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 use overload
32 59 ▶ '""' => \&full_msg_and_trace,
Subroutine BEGIN: called CC=1 SCAR=0.0
33 59 'bool' => \&is_error;
34  
35 59 has description => (
36 is => 'ro',
37 isa => 'Str',
38 lazy_build => 1
39 );
40  
41 32 ▶sub _build_description {
Subroutine _build_description: called CC=1 SCAR=0.0
42 32 my $self = shift;
43 32 return $self->_desc;
44 }
45  
46 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
47 0 return 'config error' ;
48 }
49  
50 59 has object => ( is => 'rw', isa => 'Ref') ;
51 59 has info => (is => 'rw', isa =>'Str', default => '');
52 59 has message => (is => 'rw', isa =>'Str', default => '');
53 59 has error => (is => 'rw', isa =>'Str', default => '');
54 59 has trace => (is => 'rw', isa =>'Str', default => '');
55  
56 # need to keep these objects around: in some tests the error() method is
57 # called after the instance is garbage collected. Instances are kept
58 # as weak ref in node (and othe tree objects). When instance is
59 # garbage collected, it's destroyed so error() can no longer be invoked.
60 # Solution: keep instance as error attributes.
61 59 has instance => ( is => 'rw', isa => 'Ref') ;
62  
63 147 ▶sub BUILD ($self, $) {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod documented
64 147 ▶ $self->instance($self->object->instance) if defined $self->object;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->object 139 8 147
65 147 return;
66 }
67  
68 # without this overload, a test like if ($@) invokes '""' overload
69 35 ▶sub is_error (@args) {
Subroutine is_error: called CC=1 SCAR=0.0
Pod undocumented
70 35 return ref ($args[0]);
71 }
72  
73  
74 1 ▶sub Trace {
Subroutine Trace: called CC=1 SCAR=0.0
Pod undocumented
75 1 $trace = shift;
76 1 return;
77 }
78  
79 11 ▶sub error_or_msg {
Subroutine error_or_msg: called CC=2 SCAR=7.1
Pod undocumented
80 11 my $self = shift;
81 11 ▶ return $self->error || $self->message;
Condition66%2/3
$self->error || $self->message
l!l&&r!l&&!r
1010
MC/DC0%0/2
$self->error || $self->message
$self->error $self->message
Truth table66%2/3
A || B
A= $self->errorB= $self->message
ABresult
1X1
011
000
82 }
83  
84 147 ▶sub throw ($class, @args) {
Subroutine throw: called CC=2 SCAR=6.9
Pod undocumented
85 147 my $self = $class->new(@args);
86 # when an exception is thrown, caught and rethrown, the first full
87 # trace (provided by longmess) is clobbered by a second, shorter
88 # trace (also provided by longmess). To avoid that, the first
89 # trace must be stored.
90 147 ▶ $self->trace($trace ? longmess : '') ;
Branch: 1 branch
BranchTrueFalseTotal
$Config::Model::Exception::trace ? : 3 144 147
91 147 die $self;
92 }
93  
94 2 ▶sub rethrow {
Subroutine rethrow: called CC=1 SCAR=0.0
Pod undocumented
95 2 my $self = shift;
96 2 die $self;
97 }
98  
99 29 ▶sub full_msg_and_trace {
Subroutine full_msg_and_trace: called CC=1 SCAR=0.0
Pod undocumented
100 29 my $self = shift;
101 29 my $msg = $self->full_message;
102 29 $msg .= $self->trace;
103 29 return $msg;
104 }
105  
106 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
107 1 goto &full_msg_and_trace;
108 }
109  
110 13 ▶sub full_message {
Subroutine full_message: called CC=5 SCAR=16.1
Pod undocumented
111 13 my $self = shift;
112  
113 13 my $obj = $self->object;
114 13 ▶ my $location = defined $obj ? $obj->name : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $obj ? : 9 4 13
115 13 my $msg = "Configuration item ";
116 13 ▶ $msg .= "'$location' " if $location;
Branch: 1 branch
BranchTrueFalseTotal
if $location 9 4 13
117 13 $msg .= "has a " . $self->description;
118 13 ▶ $msg .= ":\n\t" . ($self->error || $self->message) . "\n";
Condition66%2/3
$self->error || $self->message
l!l&&r!l&&!r
1030
MC/DC0%0/2
$self->error || $self->message
$self->error $self->message
Truth table66%2/3
A || B
A= $self->errorB= $self->message
ABresult
1X1
011
000
119 13 ▶ $msg .= $self->info . "\n" if $self->info;
Branch: 1 branch
BranchTrueFalseTotal
if $self->info 1 12 13
120 13 return $msg;
121 }
122  
123 package Config::Model::Exception::Any 2.169;
124  
125 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
126 59 extends 'Config::Model::Exception';
127  
128 package Config::Model::Exception::ModelDeclaration 2.169;
129  
130 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
131 59 extends 'Config::Model::Exception::Fatal';
132  
133 2 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
134 2 return 'configuration model declaration error' ;
135 }
136  
137 package Config::Model::Exception::User 2.169;
138  
139 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
140 59 extends 'Config::Model::Exception::Any';
141 1 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
142 1 return 'user error' ;
143 }
144  
145  
146 ## old classes below
147 package Config::Model::Exception::Syntax 2.169;
148  
149 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
150 59 extends 'Config::Model::Exception::Any';
151  
152 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
153 0 return 'syntax error' ;
154 }
155  
156 59 has [qw/parsed_file parsed_line/] => (is => 'rw');
157  
158 0 ▶sub full_message {
Subroutine full_message: not called CC=3 SCAR=24.8
Pod undocumented
159 0 my $self = shift;
160  
161 0 ▶ my $fn = $self->parsed_file || '?';
Condition0%0/2
$self->parsed_file || '?'
l!l
00
MC/DC0%0/1
$self->parsed_file || '?'
$self->parsed_file
Truth table0%0/2
A
A= $self->parsed_file
Aresult
11
00
162 0 ▶ my $line = $self->parsed_line || '?';
Condition0%0/2
$self->parsed_line || '?'
l!l
00
MC/DC0%0/1
$self->parsed_line || '?'
$self->parsed_line
Truth table0%0/2
A
A= $self->parsed_line
Aresult
11
00
163 0 my $msg = "File $fn line $line ";
164 0 $msg .= "has a " . $self->description;
165 0 $msg .= ":\n\t" . $self->error_or_msg . "\n";
166  
167 0 return $msg;
168 }
169  
170 package Config::Model::Exception::LoadData 2.169;
171  
172 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
173 59 extends 'Config::Model::Exception::User';
174  
175 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
176 0 return 'Load data structure (perl) error' };
177 ;
178  
179 59 has wrong_data => (is => 'rw');
180  
181 0 ▶sub full_message {
Subroutine full_message: not called CC=4 SCAR=30.0
Pod undocumented
182 0 my $self = shift;
183  
184 0 my $obj = $self->object;
185 0 ▶ my $location = defined $obj ? $obj->name : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $obj ? : 0 0 0
186 0 my $msg = "Configuration item ";
187 0 my $d = Data::Dumper->new( [ $self->wrong_data ], ['wrong data'] );
188 0 $d->Sortkeys(1);
189 0 ▶ $msg .= "'$location' " if $location;
Branch: 1 branch
BranchTrueFalseTotal
if $location 0 0 0
190 0 ▶ $msg .= "(class " . $obj->config_class_name . ") " if $obj->get_type eq 'node';
Branch: 1 branch
BranchTrueFalseTotal
if $obj->get_type eq "node" 0 0 0
191 0 $msg .= "has a " . $self->description;
192 0 $msg .= ":\n\t" . $self->error_or_msg . "\n";
193 0 $msg .= $d->Dump;
194  
195 0 return $msg;
196 }
197  
198 package Config::Model::Exception::Model 2.169;
199  
200 59 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
201 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
202 59 extends 'Config::Model::Exception::Fatal';
203  
204 2 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
205 2 return 'configuration model error';
206 }
207  
208  
209 2 ▶sub full_message {
Subroutine full_message: called CC=4 SCAR=14.2
Pod undocumented
210 2 my $self = shift;
211  
212 2 ▶ my $obj = $self->object
Condition50%1/2
$self->object || croak('Internal error: no object parameter passed while throwing exception')
l!l
20
MC/DC0%0/1
$self->object || croak('Internal error: no object parameter passed while throwing exception')
$self->object
Truth table50%1/2
A
A= $self->object
Aresult
11
00
213 || croak "Internal error: no object parameter passed while throwing exception";
214 2 my $msg;
215 2 ▶ if ( $obj->isa('Config::Model::Node') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->isa('Config::Model::Node')) { } 0 2 2
216 0 $msg = "Node '" . $obj->name . "' of class " . $obj->config_class_name . ' ';
217 }
218 else {
219 2 my $element = $obj->element_name;
220 2 my $level = $obj->parent->get_element_property(
221 element => $element,
222 property => 'level'
223 );
224 2 my $location = $obj->location;
225 2 $msg = "In config class '" . $obj->parent->config_class_name. "',";
226 2 ▶ $msg .= " (location: $location)" if $location;
Branch: 1 branch
BranchTrueFalseTotal
if $location 2 0 2
227 2 $msg .= " element '$element' (level $level) ";
228 }
229 2 $msg .= "has a " . $self->description;
230 2 $msg .= ":\n\t" . $self->error_or_msg . "\n";
231  
232 2 return $msg;
233 }
234  
235 package Config::Model::Exception::Load 2.169;
236  
237 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
238 59 extends 'Config::Model::Exception::User';
239  
240 9 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
241 9 return 'Load command error';
242 }
243  
244 59 has command => (is => 'rw', isa => 'ArrayRef|Str');
245  
246 9 ▶sub full_message {
Subroutine full_message: called CC=7 SCAR=19.6
Pod undocumented
247 9 my $self = shift;
248  
249 9 ▶ my $location = defined $self->object ? $self->object->name : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->object ? : 7 2 9
250 9 my $msg = $self->description;
251 9 my $cmd = $self->command;
252  
253 my $cmd_str =
254 9 ▶ ref($cmd) ? join('', map { $_ // '<undef>' } @$cmd)
Branch: 3 branches
BranchTrueFalseTotal
ref $cmd ? : 1 8 9
$cmd ? : 8 0 8
defined $cmd ? : 0 0 0
Condition100%2/2
$_ // "<undef>"
l!l
34
MC/DC100%1/1
$_ // "<undef>"
$_
Truth table100%2/2
A
A= $_
Aresult
11
00
255 : $cmd ? "'$cmd'"
256 : defined $cmd ? '<empty>'
257 : '<undef>';
258 9 ▶ $msg .= " in node '$location' " if $location;
Branch: 1 branch
BranchTrueFalseTotal
if $location 7 2 9
259 9 $msg .= ':';
260 9 $msg .= "\n\tcommand: $cmd_str";
261 9 $msg .= "\n\t" . $self->error_or_msg . "\n";
262  
263 9 return $msg;
264 }
265  
266 package Config::Model::Exception::UnavailableElement 2.169;
267  
268 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
269 59 extends 'Config::Model::Exception::User';
270  
271 2 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
272 2 return 'unavailable element';
273 }
274  
275 59 has [qw/element function/] => (is => 'rw', isa => 'Str');
276  
277  
278 2 ▶sub full_message {
Subroutine full_message: called CC=4 SCAR=14.0
Pod undocumented
279 2 my $self = shift;
280  
281 2 my $obj = $self->object;
282 2 my $location = $obj->name;
283 2 my $msg = $self->description;
284 2 my $element = $self->element;
285 2 my $function = $self->function;
286 2 my $unavail = $obj->fetch_element(
287 name => $element,
288 check => 'no',
289 accept_hidden => 1
290 );
291 2 $msg .= " '$element' in node '$location'.\n";
292 2 ▶ $msg .= "\tError occurred when calling $function.\n" if defined $function;
Branch: 1 branch
BranchTrueFalseTotal
if defined $function 0 2 2
293 2 ▶ $msg .= "\t" . $unavail->warp_error if $unavail->can('warp_error');
Branch: 1 branch
BranchTrueFalseTotal
if $unavail->can("warp_error") 2 0 2
294  
295 2 ▶ $msg .= "\t" . $self->info . "\n" if defined $self->info;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->info 2 0 2
296 2 return $msg;
297 }
298  
299 package Config::Model::Exception::AncestorClass 2.169;
300  
301 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
302 59 extends 'Config::Model::Exception::User';
303  
304 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
305 0 return 'unknown ancestor class';
306 }
307  
308  
309 package Config::Model::Exception::ObsoleteElement 2.169;
310  
311 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
312 59 extends 'Config::Model::Exception::User';
313  
314 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
315 0 return 'Obsolete element' ;
316 }
317  
318 59 has element => (is => 'rw', isa => 'Str');
319  
320 0 ▶sub full_message {
Subroutine full_message: not called CC=3 SCAR=24.8
Pod undocumented
321 0 my $self = shift;
322  
323 0 my $obj = $self->object;
324 0 my $element = $self->element;
325 0 my $msg = $self->description;
326  
327 0 my $location = $obj->name;
328 0 ▶ my $help = $obj->get_help_as_text($element) || '';
Condition0%0/2
$obj->get_help_as_text($element) || ''
l!l
00
MC/DC0%0/1
$obj->get_help_as_text($element) || ''
$obj->get_help_as_text($element)
Truth table0%0/2
A
A= $obj->get_help_as_text($element)
Aresult
11
00
329  
330 0 $msg .= " '$element' in node '$location'.\n";
331 0 $msg .= "\t$help\n";
332 0 ▶ $msg .= "\t" . $self->info . "\n" if defined $self->info;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->info 0 0 0
333 0 return $msg;
334 }
335  
336 package Config::Model::Exception::UnknownElement 2.169;
337  
338 59 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
339  
340 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
341 59 extends 'Config::Model::Exception::User';
342  
343 4 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
344 4 return 'unknown element' ;
345 }
346  
347 59 has [qw/element function where autoadd/] => (is => 'rw');
348  
349 2 ▶sub full_message {
Subroutine full_message: called CC=16 SCAR=35.7
Pod undocumented
350 2 my $self = shift;
351  
352 2 my $obj = $self->object;
353  
354 2 ▶ confess "Exception::UnknownElement: object is ", ref($obj), ". Expected a node"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $obj and $obj->isa("Config::Model::Node") || $obj->isa("Config::Model::WarpedNode") 0 2 2
Condition33%2/6
ref $obj and $obj->isa("Config::Model::Node") || $obj->isa("Config::Model::WarpedNode")
!ll&&!rl&&r
002
$obj->isa("Config::Model::Node") or $obj->isa("Config::Model::WarpedNode")
l!l&&r!l&&!r
200
MC/DC0%0/3
ref $obj and $obj->isa("Config::Model::Node") || $obj->isa("Config::Model::WarpedNode")
ref $obj $obj->isa("Config::Model::Node") $obj->isa("Config::Model::WarpedNode")
Truth table25%1/4
A and B or C
A= ref $objB= $obj->isa("Config::Model::Node")C= $obj->isa("Config::Model::WarpedNode")
ABCresult
0XX0
1000
11X1
1011
355 unless ref($obj) && ($obj->isa('Config::Model::Node')
356 || $obj->isa('Config::Model::WarpedNode'));
357  
358 2 my $class_name = $obj->config_class_name;
359  
360 # class_name is undef if the warped_node is warped out
361 2 my @elements;
362 2 ▶ @elements = $obj->get_element_name(
Branch: 1 branch
BranchTrueFalseTotal
if defined $class_name 2 0 2
363 class => $class_name,
364 ) if defined $class_name;
365  
366 2 my $msg = '';
367 2 ▶ $msg .= "Configuration path '" . $self->where . "': "
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->where 0 2 2
368 if defined $self->where;
369  
370 2 ▶ $msg .= "(function '" . $self->function . "') "
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->function 2 0 2
371 if defined $self->function;
372  
373 2 ▶ $msg = "object '" . $obj->name . "' error: " unless $msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg 0 2 2
374  
375 2 $msg .= $self->description . " '" . $self->element . "'.";
376  
377 # retrieve a support url from application info to guide user toward the right bug tracker
378 2 ▶ my $info = $obj->instance->get_support_info // 'to https://github.com/dod38fr/config-model/issues';
Condition50%1/2
$obj->instance->get_support_info // "to https://github.com/dod38fr/config-model/issues"
l!l
02
MC/DC0%0/1
$obj->instance->get_support_info // "to https://github.com/dod38fr/config-model/issues"
$obj->instance->get_support_info
Truth table50%1/2
A
A= $obj->instance->get_support_info
Aresult
11
00
379 2 $msg .=
380 " Either your file has an error or $class_name model is lagging behind. "
381 . "In the latter case, please submit a bug report $info. See cme man "
382 . "page for details.\n";
383  
384 2 ▶ if (@elements) {
Branch: 1 branch
BranchTrueFalseTotal
if (@elements) { } 2 0 2
385 2 $msg .= "\tExpected elements: '" . join( "','", @elements ) . "'\n";
386 }
387 else {
388 0 $msg .= " (node is warped out)\n";
389 }
390  
391 2 ▶ my @match_keys = $obj->can('accept_regexp') ? $obj->accept_regexp() : ();
Branch: 1 branch
BranchTrueFalseTotal
$obj->can('accept_regexp') ? : 2 0 2
392 2 ▶ if (@match_keys and $self->autoadd) {
Branch: 1 branch
BranchTrueFalseTotal
if (@match_keys and $self->autoadd) 0 2 2
Condition33%1/3
@match_keys and $self->autoadd
!ll&&!rl&&r
200
MC/DC0%0/2
@match_keys and $self->autoadd
@match_keys $self->autoadd
Truth table33%1/3
A and B
A= @match_keysB= $self->autoadd
ABresult
0X0
100
111
393 0 $msg .= "\tor an acceptable parameter matching '" . join( "','", @match_keys ) . "'\n";
394 }
395  
396 # inform about available elements after a change of warp master value
397 2 ▶ if ( defined $obj->parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj->parent) 0 2 2
398 0 my $parent = $obj->parent;
399 0 my $element_name = $obj->element_name;
400  
401 0 ▶ if ( $parent->element_type($element_name) eq 'warped_node' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->element_type($element_name) eq "warped_node") 0 0 0
402 0 $msg .= "\t"
403 . $parent->fetch_element(
404 name => $element_name,
405 qw/check no accept_hidden 1/
406 )->warp_error;
407 }
408 }
409  
410 2 ▶ $msg .= "\t" . $self->info . "\n" if ( defined $self->info );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->info 2 0 2
411  
412 2 return $msg;
413 }
414  
415 package Config::Model::Exception::WarpError 2.169;
416  
417 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
418 59 extends 'Config::Model::Exception::User';
419  
420 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
421 0 return 'warp error';
422 }
423  
424 package Config::Model::Exception::Fatal 2.169;
425  
426 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
427 59 extends 'Config::Model::Exception::Any';
428  
429 1 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
430 1 return 'fatal error' ;
431 }
432  
433  
434 package Config::Model::Exception::UnknownId 2.169;
435  
436 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
437 59 extends 'Config::Model::Exception::User';
438  
439 1 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
440 1 return 'unknown identifier';
441 }
442  
443 59 has [qw/element id function where/] => (is => 'rw', isa => 'Str');
444  
445 1 ▶sub full_message {
Subroutine full_message: called CC=3 SCAR=11.1
Pod undocumented
446 1 my $self = shift;
447  
448 1 my $obj = $self->object;
449  
450 1 my $element = $self->element;
451 1 my $id_str = "'" . join( "','", $obj->fetch_all_indexes() ) . "'";
452  
453 1 my $msg = '';
454 1 ▶ $msg .= "In function " . $self->function . ": "
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->function 1 0 1
455 if defined $self->function;
456  
457 1 ▶ $msg .= "In " . $self->where . ": "
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->where 0 1 1
458 if defined $self->where;
459  
460 1 $msg .=
461 $self->description . " '"
462 . $self->id() . "'"
463 . " for element '"
464 . $obj->location
465 . "'\n\texpected: $id_str\n";
466  
467 1 return $msg;
468 }
469  
470 package Config::Model::Exception::WrongValue 2.169;
471  
472 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
473 59 extends 'Config::Model::Exception::User';
474  
475 8 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
476 8 return 'wrong value'};
477 ;
478  
479  
480 package Config::Model::Exception::WrongType 2.169;
481  
482 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
483 59 extends 'Config::Model::Exception::User';
484  
485 1 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
486 1 return 'wrong element type' };
487 ;
488  
489 59 has [qw/function got_type/] => (is => 'rw', isa => 'Str');
490 59 has [qw/expected_type/] => (is => 'rw');
491  
492 1 ▶sub full_message {
Subroutine full_message: called CC=3 SCAR=11.2
Pod undocumented
493 1 my $self = shift;
494  
495 1 my $obj = $self->object;
496  
497 1 my $msg = '';
498 1 ▶ $msg .= "In function " . $self->function . ": "
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->function 1 0 1
499 if defined $self->function;
500  
501 1 my $type = $self->expected_type;
502  
503 1 ▶ $msg .=
Branch: 1 branch
BranchTrueFalseTotal
ref $type ? : 0 1 1
504 $self->description
505 . " for element '"
506 . $obj->location
507 . "'\n\tgot type '"
508 . $self->got_type
509 . "', expected '"
510 . (ref $type ? join("' or '",@$type) : $type) . "' "
511 . $self->info . "\n";
512  
513 1 return $msg;
514 }
515  
516 package Config::Model::Exception::ConfigFile 2.169;
517  
518 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
519 59 extends 'Config::Model::Exception::User';
520  
521 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
522 0 return 'error in configuration file' ;
523 }
524  
525 package Config::Model::Exception::ConfigFile::Missing 2.169;
526  
527 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
528 59 ▶use Mouse::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
529  
530 59 extends 'Config::Model::Exception::ConfigFile';
531  
532 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
533 0 return 'missing configuration file';
534 }
535  
536 0 ▶subtype 'ExcpPathTiny', as 'Object', where {$_->isa('Path::Tiny')} ;
Subroutine __ANON__: not called CC=1 SCAR=1.2
537  
538 59 has file => (is => 'rw', isa => 'Str | ExcpPathTiny' );
539  
540 0 ▶sub full_message {
Subroutine full_message: not called CC=1 SCAR=6.9
Pod undocumented
541 0 my $self = shift;
542  
543 0 return "Error: cannot find configuration file " . $self->file . "\n";
544 }
545  
546 package Config::Model::Exception::Formula 2.169;
547  
548 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
549 59 extends 'Config::Model::Exception::Model';
550  
551 0 ▶sub _desc {
Subroutine _desc: not called CC=1 SCAR=6.9
552 0 return 'error in computation formula of the configuration model';
553 }
554  
555 package Config::Model::Exception::Internal 2.169;
556  
557 59 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
558 59 extends 'Config::Model::Exception::Fatal';
559  
560 1 ▶sub _desc {
Subroutine _desc: called CC=1 SCAR=0.0
561 1 return 'internal error' ;
562 }
563  
564 59 1;
565  
566 # ABSTRACT: Exception mechanism for configuration model
567  
568 __END__
« blib/lib/Config/Model/Role/ComputeFunction.pm ↑ Summary blib/lib/Config/Model/AnyThing.pm »