Parse/Exceptions.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 34 / 34 CC 4 SCAR 10.0
CC
4
Cov
100%
full_message
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Parse.pm ↑ Summary
1 #
2 #===============================================================================
3 #
4 # FILE: Games::Go::AGA::Parse::Exceptions.pm
5 #
6 # DESCRIPTION: Exception classes for AGA parsers
7 #
8 # PODNAME: Games::Go::AGA::Parse::Exceptions
9 # ABSTRACT: Exceptions classes for AGA Parsers
10 #
11 # AUTHOR: Reid Augustin (REID), <reid@lucidport.com>
12 # COMPANY: LucidPort Technology, Inc.
13 # CREATED: 01/18/2011 01:45:36 PM
14 #===============================================================================
15  
16 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 package Games::Go::AGA::Parse::Exceptions;
20  
21 4 ▶use Exception::Class (
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 'Games::Go::AGA::Parse::Exception' => {
23 description => 'base class for AGA parser exceptions',
24 fields => ['filename', # if we know the filename
25 'handle', # if we have the file handle
26 'line_number', # if we know the line_number in the file
27 'source', # source string that caused error
28 ],
29 # alias => 'parse_exception', # Sadly, aliasing doesn't seem to work unless
30 # Exception::Class is 'use'd in the same
31 # module. Makes it fairly worthless.
32 },
33 4 );
34  
35 4 our $VERSION = '0.042'; # VERSION
36  
37 # Games::Go::AGA::Parse->Trace(1); # provide stack trace
38  
39 8 ▶sub Games::Go::AGA::Parse::Exception::full_message {
Subroutine full_message: called CC=4 SCAR=13.9
Pod documented
40 8 my ($self) = @_;
41  
42 8 my $msg = $self->error;
43 8 my $fname = $self->filename;
44 8 my $handle = $self->handle;
45 8 my $line_number = $self->line_number;
46 8 my $source = $self->source;
47  
48 8 ▶ $msg .= " while parsing:\n$source\n" if ($source);
Branch: 1 branch
BranchTrueFalseTotal
if $source 5 3 8
49 8 eval {
50 8 $line_number = $handle->input_line_number;
51 };
52 8 ▶ $msg .= " at line $line_number" if ($line_number);
Branch: 1 branch
BranchTrueFalseTotal
if $line_number 3 5 8
53 8 ▶ $msg .= " in $fname" if ($fname);
Branch: 1 branch
BranchTrueFalseTotal
if $fname 4 4 8
54 8 return $msg;
55 }
56  
57 4 1;
58  
59 __END__
« Parse.pm ↑ Summary