File Coverage

blib/lib/Games/Go/AGA/Parse/Exceptions.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 31 31 100.0


line stmt bran cond sub pod time code
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),
12             # COMPANY: LucidPort Technology, Inc.
13             # CREATED: 01/18/2011 01:45:36 PM
14             #===============================================================================
15              
16 4     4   544 use strict;
  4         5  
  4         147  
17 4     4   19 use warnings;
  4         7  
  4         224  
18              
19             package Games::Go::AGA::Parse::Exceptions;
20              
21             use Exception::Class (
22 4         44 '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     4   2506 );
  4         32639  
34              
35             our $VERSION = '0.042'; # VERSION
36              
37             # Games::Go::AGA::Parse->Trace(1); # provide stack trace
38              
39             sub Games::Go::AGA::Parse::Exception::full_message {
40 8     8   8896 my ($self) = @_;
41              
42 8         50 my $msg = $self->error;
43 8         214 my $fname = $self->filename;
44 8         178 my $handle = $self->handle;
45 8         175 my $line_number = $self->line_number;
46 8         184 my $source = $self->source;
47              
48 8 100       66 $msg .= " while parsing:\n$source\n" if ($source);
49 8         20 eval {
50 8         53 $line_number = $handle->input_line_number;
51             };
52 8 100       29 $msg .= " at line $line_number" if ($line_number);
53 8 100       25 $msg .= " in $fname" if ($fname);
54 8         32 return $msg;
55             }
56              
57             1;
58              
59             __END__