From: Peter Rabbitson Date: Fri, 18 Sep 2009 12:36:29 +0000 (+0000) Subject: Factor out dumper copy/paste X-Git-Tag: v0.08113~32^2~4^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b561bb6fb2ddc0faada3313934fec2f14d62a625;p=dbsrgits%2FDBIx-Class.git Factor out dumper copy/paste --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 5d7a665..ee5eed0 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -75,6 +75,19 @@ sub _attr_cache { sub _sqlt_minimum_version { $minimum_sqlt_version }; } +# Pretty printer for debug messages +sub _pretty_print { + + require Data::Dumper; + local $Data::Dumper::Terse = 1; + local $Data::Dumper::Indent = 1; + local $Data::Dumper::Useqq = 1; + local $Data::Dumper::Quotekeys = 0; + local $Data::Dumper::Sortkeys = 1; + + return Data::Dumper::Dumper ($_[1]); +} + 1; diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1ce71fc..5d3a6c0 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1419,18 +1419,11 @@ sub insert_bulk { $self->throw_exception("Unexpected populate error: $err") if ($i > $#$tuple_status); - require Data::Dumper; - local $Data::Dumper::Terse = 1; - local $Data::Dumper::Indent = 1; - local $Data::Dumper::Useqq = 1; - local $Data::Dumper::Quotekeys = 0; - local $Data::Dumper::Sortkeys = 1; - $self->throw_exception(sprintf "%s for populate slice:\n%s", ($tuple_status->[$i][1] || $err), - Data::Dumper::Dumper( - { map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols) } - ), + $self->_pretty_print ({ + map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols) + }), ); } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 219ca56..bccd0b4 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -696,18 +696,11 @@ EOF $self->throw_exception("Unexpected populate error: $err") if ($i > $#$tuple_status); - require Data::Dumper; - local $Data::Dumper::Terse = 1; - local $Data::Dumper::Indent = 1; - local $Data::Dumper::Useqq = 1; - local $Data::Dumper::Quotekeys = 0; - local $Data::Dumper::Sortkeys = 1; - $self->throw_exception(sprintf "%s for populate slice:\n%s", ($tuple_status->[$i][1] || $err), - Data::Dumper::Dumper( - { map { $source_columns[$_] => $new_data[$i][$_] } (0 .. $#$cols) } - ), + $self->_pretty_print ({ + map { $source_columns[$_] => $new_data[$i][$_] } (0 .. $#$cols) + }), ); } @@ -849,15 +842,11 @@ sub _insert_blobs { my $sth = $cursor->sth; if (not $sth) { - require Data::Dumper; - local $Data::Dumper::Terse = 1; - local $Data::Dumper::Indent = 1; - local $Data::Dumper::Useqq = 1; - local $Data::Dumper::Quotekeys = 0; - local $Data::Dumper::Sortkeys = 1; - - croak "\nCould not find row in table '$table' for blob update:\n". - Data::Dumper::Dumper(\%where)."\n"; + + $self->throw_exception( + "Could not find row in table '$table' for blob update:\n" + . $self->_pretty_print (\%where) + ); } eval {