/usr/share/perl5/RDF/Trine/Error.pm is in librdf-trine-perl 1.014-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | # RDF::Trine::Error
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Error - Error classes for RDF::Trine
=head1 VERSION
This document describes RDF::Trine::Error version 1.014
=head1 SYNOPSIS
use RDF::Trine::Error qw(:try);
=head1 DESCRIPTION
RDF::Trine::Error provides a class hierarchy of errors that other RDF::Trine
classes may throw using the L<Error|Error> API. See L<Error> for more
information.
=head1 REQUIRES
L<Error|Error>
=cut
package RDF::Trine::Error;
use strict;
use warnings;
no warnings 'redefine';
use Carp qw(carp croak confess);
use base qw(Error);
######################################################################
our ($VERSION);
BEGIN {
$VERSION = '1.014';
}
######################################################################
package RDF::Trine::Error::CompilationError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::QuerySyntaxError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::MethodInvocationError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::SerializationError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::DatabaseError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::ParserError;
use base qw(RDF::Trine::Error);
package RDF::Trine::Error::ParserError::Explainable;
use base qw(RDF::Trine::Error::ParserError);
use Module::Load::Conditional qw[can_load];
our $ANSI;
BEGIN {
$ANSI = can_load( modules => { 'Term::ANSIColor' => undef } );
}
sub _get_line {
my $self = shift;
my $fh = shift;
my $line = shift;
my $buffer;
do {
$buffer = $fh->getline;
} while (--$line);
return $buffer;
}
package RDF::Trine::Error::ParserError::Tokenized;
use base qw(RDF::Trine::Error::ParserError::Explainable);
sub explain {
my $self = shift;
my $fh = shift;
seek($fh, 0, 0);
my $text = $self->text;
my $t = $self->object;
my $line = $t->start_line;
my $col = $t->start_column;
my $buffer = $self->_get_line( $fh, $line );
my $maxlen = length($buffer) - $col;
my $len = 1;
if ($t->line == $t->start_line) {
$len = ($t->column - $t->start_column);
} else {
$len = $maxlen;
}
my $tabs = ($buffer =~ tr/\t//);
$buffer =~ s/\t/ /g;
$col += 3 * $tabs;
chomp($text);
if ($RDF::Trine::Error::ParserError::Explainable::ANSI) {
print STDERR Term::ANSIColor::color('red');
print STDERR "$text:\n";
print STDERR Term::ANSIColor::color('reset');
print STDERR substr($buffer, 0, $col-1);
print STDERR Term::ANSIColor::color('red');
print STDERR substr($buffer, $col-1, $len);
print STDERR Term::ANSIColor::color('reset');
print STDERR substr($buffer, $col+$len-1);
print STDERR " " x ($col-1);
print STDERR Term::ANSIColor::color('blue');
print STDERR "^";
if ($len > 1) {
print STDERR ("~" x ($len-1));
}
print STDERR "\n";
print STDERR Term::ANSIColor::color('reset');
} else {
print STDERR "$text:\n";
print STDERR $buffer;
print STDERR " " x ($col-1);
print STDERR "^";
if ($len > 1) {
print STDERR ("~" x ($len-1));
}
print STDERR "\n";
}
}
package RDF::Trine::Error::ParserError::Positioned;
use base qw(RDF::Trine::Error::ParserError::Explainable);
sub explain {
my $self = shift;
my $fh = shift;
seek($fh, 0, 0);
my $text = $self->text;
my $pos = $self->value;
my ($line, $col) = @$pos;
my $buffer = $self->_get_line( $fh, $line ) || '';
my $tabs = ($buffer =~ tr/\t//);
$buffer =~ s/\t/ /g;
$col += 3 * $tabs;
chomp($text);
if ($RDF::Trine::Error::ParserError::Explainable::ANSI) {
print STDERR Term::ANSIColor::color('red');
print STDERR "$text:\n";
print STDERR Term::ANSIColor::color('reset');
print STDERR $buffer;
print STDERR Term::ANSIColor::color('red');
print STDERR " " x ($col-1);
print STDERR "^";
print STDERR Term::ANSIColor::color('reset');
print STDERR "\n";
} else {
print STDERR "$text:\n";
print STDERR $buffer;
print STDERR " " x ($col-1);
print STDERR "^";
print STDERR "\n";
}
}
package RDF::Trine::Error::UnimplementedError;
use base qw(RDF::Trine::Error);
1;
__END__
=head1 BUGS
Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/perlrdf/issues>.
=head1 AUTHOR
Gregory Todd Williams C<< <gwilliams@cpan.org> >>
=head1 COPYRIGHT
Copyright (c) 2006-2012 Gregory Todd Williams. This
program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|