| 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
| |||||||||||
| 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
| |||||||||||
| 53 | 8 | ▶ | $msg .= " in $fname" if ($fname); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 8 | return $msg; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 4 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||