Skip to content

Commit

Permalink
Error Cleanup: transaction aborted (Pg)
Browse files Browse the repository at this point in the history
  • Loading branch information
chizmw committed Dec 2, 2011
1 parent f75cbba commit 1dcc840
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents the revision history for Catalyst::Plugin::ErrorCatcher
- (author) update dzil config with current preferred preferences
- (author) Copy README.mkdn to root on a 'dzil build'
- Error Cleanup: foreign key constraint violation (Pg)
- Error Cleanup: transaction aborted (Pg)

0.0.8.9 2011-07-18 17:26:58 Europe/London
- drop Class::Data::Accessor in favour of Catalyst::ClassData
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::TransactionAborted;
use strict;
use warnings;

sub tidy_message {
my $plugin = shift;
my $errstr_ref = shift;

# ERROR: current transaction is aborted, commands ignored until end of
# transaction block [for Statement
${$errstr_ref} =~ s{
\A
.+?
DBI \s Exception:
.+?
ERROR:\s+
(
current \s transaction \s is \s aborted, \s
commands \s ignored \s until \s end \s of \s transaction \s block
)
\s \[ for \s Statement
\s+
.+
$
}{$1}xmsg;

$errstr_ref;
}

1;



7 changes: 6 additions & 1 deletion t/04.cleaned.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ my @test_cases = (
{
original => qq{Error: encountered object 'DBIx::Class::AuditLog::delete(): DBI Exception: DBD::Pg::st execute failed: ERROR: update or delete on table "TheTable" violates foreign key constraint "foo_fkey" on table "fkey_table"\nDETAIL: Key (id, thing_id)=(1, 5) is still referenced from table "fkey_table". [for Statement "DELETE FROM public.thingy WHERE ( id = ? )" with ParamValues: 1='1']},
cleaned => q{Foreign key constraint violation: TheTable -> fkey_table [foo_fkey]},
}
},

{
original => q{Error: DBIx::Class::AuditLog::update(): DBI Exception: DBD::Pg::st execute failed: ERROR: current transaction is aborted, commands ignored until end of transaction block [for Statement "INSERT INTO some.table ( col1, col2 ) VALUES ( ?, ? ) RETURNING id" with ParamValues: 1='one', 2='two'] at /opt/someapp/script/lib/SomeModule line 69},
cleaned => q{current transaction is aborted, commands ignored until end of transaction block},
},
);

foreach my $test (@test_cases) {
Expand Down

0 comments on commit 1dcc840

Please sign in to comment.