File Coverage

blib/lib/Protocol/Database/PostgreSQL/Error.pm
Criterion Covered Total %
statement 9 17 52.9
branch n/a
condition 0 2 0.0
subroutine 3 11 27.2
pod 8 8 100.0
total 20 38 52.6


line stmt bran cond sub pod time code
1             package Protocol::Database::PostgreSQL::Error;
2              
3 1     1   10 use strict;
  1         3  
  1         32  
4 1     1   5 use warnings;
  1         2  
  1         43  
5              
6             our $VERSION = '1.005'; # VERSION
7              
8             =head1 NAME
9              
10             Protocol::Database::PostgreSQL::Error - represents a PostgreSQL error
11              
12             =head1 DESCRIPTION
13              
14             This inherits from L to provide a wrapper for exceptions and notices
15             raised by the server.
16              
17             =cut
18              
19 1     1   8 use parent qw(Ryu::Exception);
  1         3  
  1         4  
20              
21             =head1 METHODS
22              
23             =head2 code
24              
25             The failing code.
26              
27             =cut
28              
29 0     0 1   sub code { shift->{code} }
30              
31             =head2 file
32              
33             Which PostgreSQL source file the error was raised from.
34              
35             =cut
36              
37 0     0 1   sub file { shift->{file} }
38              
39             =head2 line
40              
41             The line number in the PostgreSQL source file which raised this error.
42              
43             =cut
44              
45 0     0 1   sub line { shift->{line} }
46              
47             =head2 message
48              
49             The error message from the server.
50              
51             =cut
52              
53 0     0 1   sub message { shift->{message} }
54              
55             =head2 position
56              
57             The character offset in the input query.
58              
59             =cut
60              
61 0     0 1   sub position { shift->{position} }
62              
63             =head2 routine
64              
65             Which PostgreSQL processing routine raised this.
66              
67             =cut
68              
69 0     0 1   sub routine { shift->{routine} }
70              
71             =head2 severity
72              
73             Relative severity of the error, e.g. NOTICE or FATAL.
74              
75             =cut
76              
77 0     0 1   sub severity { shift->{severity} }
78              
79             =head2 type
80              
81             Look up the error information in tables extracted from PostgreSQL official documentation.
82             Returns a string corresponding to the error code, or C if it's not in the tables
83             (or from a newer version than this module supports, currently 11.2).
84              
85             =cut
86              
87 0   0 0 1   sub type { $Protocol::Database::PostgreSQL::ERROR_CODE{shift->{code}} // 'unknown' }
88              
89             1;
90              
91             =head1 AUTHOR
92              
93             Tom Molesworth
94              
95             =head1 LICENSE
96              
97             Copyright Tom Molesworth 2010-2019. Licensed under the same terms as Perl itself.
98