File Coverage

lib/Catalyst/Plugin/ErrorCatcher/Plugin/CleanUp/Pg/ForeignKeyConstraint.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::ForeignKeyConstraint;
2             $Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::ForeignKeyConstraint::VERSION = '0.0.8.18';
3             {
4             $Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::ForeignKeyConstraint::DIST = 'Catalyst-Plugin-ErrorCatcher';
5             }
6 9     9   8294 use strict;
  9         23  
  9         372  
7 9     9   52 use warnings;
  9         18  
  9         1371  
8              
9             sub tidy_message {
10 28     28 1 68 my $plugin = shift;
11 28         54 my $errstr_ref = shift;
12              
13             # update or delete on table "foo" violates foreign key constraint
14             # "foobar_fkey" on table "baz"
15 28         50 ${$errstr_ref} =~ s{
  28         111  
16             \A
17             .+?
18             DBI \s Exception:
19             .+?
20             ERROR:\s+
21             update \s or \s delete \s on \s table \s
22             "(.+?)" \s
23             violates \s foreign \s key \s constraint \s
24             "(.+?)" \s
25             on \s table \s
26             "(.+?)"
27             \s+
28             .+
29             $
30             }{Foreign key constraint violation: $1 -> $3 [$2]}xmsg;
31              
32 28         82 $errstr_ref;
33             }
34              
35             1;
36             # ABSTRACT: cleanup foreign key violation messages from Pg
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::ForeignKeyConstraint - cleanup foreign key violation messages from Pg
47              
48             =head1 VERSION
49              
50             version 0.0.8.18
51              
52             =head2 tidy_message($self, $stringref)
53              
54             Tidy up Postgres messages where the error is related to a I<foreign key constraint violation>.
55              
56             =head1 AUTHOR
57              
58             Chisel <chisel@chizography.net>
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2015 by Chisel Wright.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut