From: Peter Rabbitson Date: Thu, 1 Sep 2011 10:13:36 +0000 (-0400) Subject: General cleanup of error messages - quote identifiers/names where sensible X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e705f5290cf384194c31a807c9bb722c7a167dfd;p=dbsrgits%2FDBIx-Class-Historic.git General cleanup of error messages - quote identifiers/names where sensible No functional changes --- diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 0e2d058..3162223 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -201,7 +201,7 @@ sub _flate_or_fallback $parser->$method($value); } catch { - $self->throw_exception ("Error while inflating ${value} for $info->{__dbic_colname} on ${self}: $_") + $self->throw_exception ("Error while inflating '$value' for $info->{__dbic_colname} on ${self}: $_") unless $info->{datetime_undef_if_invalid}; undef; # rv }; diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm index 174aa23..1609122 100644 --- a/lib/DBIx/Class/Relationship/Accessor.pm +++ b/lib/DBIx/Class/Relationship/Accessor.pm @@ -45,7 +45,7 @@ sub add_relationship_accessor { } }; } elsif ($acc_type eq 'filter') { - $class->throw_exception("No such column $rel to filter") + $class->throw_exception("No such column '$rel' to filter") unless $class->has_column($rel); my $f_class = $class->relationship_info($rel)->{class}; $class->inflate_column($rel, @@ -55,7 +55,7 @@ sub add_relationship_accessor { }, deflate => sub { my ($val, $self) = @_; - $self->throw_exception("$val isn't a $f_class") unless $val->isa($f_class); + $self->throw_exception("'$val' isn't a $f_class") unless $val->isa($f_class); return ($val->_ident_values)[0]; # WARNING: probably breaks for multi-pri sometimes. FIXME } @@ -66,7 +66,7 @@ sub add_relationship_accessor { $meth{"${rel}_rs"} = sub { shift->search_related_rs($rel, @_) }; $meth{"add_to_${rel}"} = sub { shift->create_related($rel, @_); }; } else { - $class->throw_exception("No such relationship accessor type $acc_type"); + $class->throw_exception("No such relationship accessor type '$acc_type'"); } { no strict 'refs'; diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 5338cb6..41c7a8a 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -445,7 +445,7 @@ sub related_resultset { unless ref $self; my $rel = shift; my $rel_info = $self->relationship_info($rel); - $self->throw_exception( "No such relationship ${rel}" ) + $self->throw_exception( "No such relationship '$rel'" ) unless $rel_info; return $self->{related_resultsets}{$rel} ||= do { @@ -474,8 +474,8 @@ sub related_resultset { # keep in mind that the following if() block is part of a do{} - no return()s!!! if ($is_crosstable) { $self->throw_exception ( - "A cross-table relationship condition returned for statically declared '$rel'") - unless ref $rel_info->{cond} eq 'CODE'; + "A cross-table relationship condition returned for statically declared '$rel'" + ) unless ref $rel_info->{cond} eq 'CODE'; # A WHOREIFFIC hack to reinvoke the entire condition resolution # with the correct alias. Another way of doing this involves a @@ -781,11 +781,11 @@ sub set_from_related { my $rsrc = $self->result_source; my $rel_info = $rsrc->relationship_info($rel) - or $self->throw_exception( "No such relationship ${rel}" ); + or $self->throw_exception( "No such relationship '$rel'" ); if (defined $f_obj) { my $f_class = $rel_info->{class}; - $self->throw_exception( "Object $f_obj isn't a ".$f_class ) + $self->throw_exception( "Object '$f_obj' isn't a ".$f_class ) unless blessed $f_obj and $f_obj->isa($f_class); } diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index 76ffb50..e55d1bd 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -28,19 +28,19 @@ sub belongs_to { $class->ensure_class_loaded($f_class); my %f_primaries = map { $_ => 1 } try { $f_class->_pri_cols } catch { - $class->throw_exception( "Can't infer join condition for ${rel} on ${class}: $_"); + $class->throw_exception( "Can't infer join condition for '$rel' on ${class}: $_"); }; my ($pri, $too_many) = keys %f_primaries; $class->throw_exception( - "Can't infer join condition for ${rel} on ${class}; ". - "${f_class} has multiple primary keys" + "Can't infer join condition for '$rel' on ${class}: " + . "${f_class} has multiple primary keys" ) if $too_many; my $fk = defined $cond ? $cond : $rel; $class->throw_exception( - "Can't infer join condition for ${rel} on ${class}; ". - "$fk is not a column of $class" + "Can't infer join condition for '$rel' on ${class}: " + . "'$fk' is not a column of $class" ) unless $class->has_column($fk); $cond = { "foreign.${pri}" => "self.${fk}" }; diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index b8a9b4c..16fa0ba 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -18,7 +18,7 @@ sub has_many { $class->ensure_class_loaded($f_class); my ($pri, $too_many) = try { $class->_pri_cols } catch { - $class->throw_exception("Can't infer join condition for ${rel} on ${class}: $_"); + $class->throw_exception("Can't infer join condition for '$rel' on ${class}: $_"); }; $class->throw_exception( @@ -43,7 +43,7 @@ sub has_many { my $f_class_loaded = try { $f_class->columns }; $class->throw_exception( - "No such column ${f_key} on foreign class ${f_class} ($guess)" + "No such column '$f_key' on foreign class ${f_class} ($guess)" ) if $f_class_loaded && !$f_class->has_column($f_key); $cond = { "foreign.${f_key}" => "self.${pri}" }; diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index f9046ca..09ea77c 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -45,7 +45,7 @@ sub _has_one { $guess = "using primary key of foreign class for foreign key"; } $class->throw_exception( - "No such column ${f_key} on foreign class ${f_class} ($guess)" + "No such column '$f_key' on foreign class ${f_class} ($guess)" ) if $f_class_loaded && !$f_class->has_column($f_key); $cond = { "foreign.${f_key}" => "self.${pri}" }; } @@ -90,7 +90,7 @@ sub _validate_has_one_condition { # warning return unless $self_id =~ /^self\.(.*)$/; my $key = $1; - $class->throw_exception("Defining rel on ${class} that includes ${key} but no such column defined here yet") + $class->throw_exception("Defining rel on ${class} that includes '$key' but no such column defined here yet") unless $class->has_column($key); my $column_info = $class->column_info($key); if ( $column_info->{is_nullable} ) { diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 4c7110f..0daf5cb 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -259,7 +259,7 @@ sub new { next; } } - $new->throw_exception("No such column $key on $class") + $new->throw_exception("No such column '$key' on $class") unless $class->has_column($key); $new->store_column($key => $attrs->{$key}); } diff --git a/lib/DBIx/Class/Storage/DBI/ACCESS.pm b/lib/DBIx/Class/Storage/DBI/ACCESS.pm index a6f174e..9384117 100644 --- a/lib/DBIx/Class/Storage/DBI/ACCESS.pm +++ b/lib/DBIx/Class/Storage/DBI/ACCESS.pm @@ -70,11 +70,9 @@ sub insert { $columns_info->{$_}{is_auto_increment} } keys %$columns_info; - if (not $autoinc_col) { - $self->throw_exception( -'empty insert only supported for tables with an autoincrement column' - ); - } + $self->throw_exception( + 'empty insert only supported for tables with an autoincrement column' + ) unless $autoinc_col; my $table = $source->from; $table = $$table if ref $table; diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 30b66fe..679fe7c 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -118,8 +118,8 @@ sub _select_args_to_query { scalar $self->_extract_order_criteria ($attrs->{order_by}) ) { $self->throw_exception( - 'An ordered subselect encountered - this is not safe! Please see "Ordered Subselects" in DBIx::Class::Storage::DBI::MSSQL - ') unless $attrs->{unsafe_subselect_ok}; + 'An ordered subselect encountered - this is not safe! Please see "Ordered Subselects" in DBIx::Class::Storage::DBI::MSSQL' + ) unless $attrs->{unsafe_subselect_ok}; my $max = $self->sql_maker->__max_int; $sql =~ s/^ \s* SELECT \s/SELECT TOP $max /xi; } diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index dc5df6f..af68023 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -203,7 +203,7 @@ sub _dbh_get_autoinc_seq { } else { $self->throw_exception( sprintf ( - "Unable to introspect trigger '%s' for column %s.%s (references multiple sequences). " + "Unable to introspect trigger '%s' for column '%s.%s' (references multiple sequences). " . "You need to specify the correct 'sequence' explicitly in '%s's column_info.", $triggers[0]{name}, $source_name, @@ -225,7 +225,7 @@ sub _dbh_get_autoinc_seq { } else { $self->throw_exception( sprintf ( - "Unable to reliably select a BEFORE INSERT trigger for column %s.%s (possibilities: %s). " + "Unable to reliably select a BEFORE INSERT trigger for column '%s.%s' (possibilities: %s). " . "You need to specify the correct 'sequence' explicitly in '%s's column_info.", $source_name, $col, @@ -246,7 +246,7 @@ sub _dbh_get_autoinc_seq { } $self->throw_exception( sprintf ( - "No suitable BEFORE INSERT triggers found for column %s.%s. " + "No suitable BEFORE INSERT triggers found for column '%s.%s'. " . "You need to specify the correct 'sequence' explicitly in '%s's column_info.", $source_name, $col, @@ -512,7 +512,7 @@ sub _prep_for_execute { my ($final_sql, @final_binds); if ($op eq 'update') { - $self->throw_exception('Update with complex WHERE clauses currently not supported') + $self->throw_exception('Update with complex WHERE clauses involving BLOB columns currently not supported') if $sql =~ /\bWHERE\b .+ \bWHERE\b/xs; my $where_sql; diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index d38f84c..3e59028 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -48,7 +48,7 @@ sub last_insert_id { for my $col (@cols) { my $seq = ( $col_info->{$col}{sequence} ||= $self->dbh_do('_dbh_get_autoinc_seq', $source, $col) ) or $self->throw_exception( sprintf( - 'could not determine sequence for column %s.%s, please consider adding a schema-qualified sequence to its column info', + "Could not determine sequence for column '%s.%s', please consider adding a schema-qualified sequence to its column info", $source->name, $col, )); @@ -95,7 +95,7 @@ sub _dbh_get_autoinc_seq { $seq_expr = '' unless defined $seq_expr; $schema = "$schema." if defined $schema && length $schema; $self->throw_exception( sprintf ( - 'no sequence found for %s%s.%s, check the RDBMS table definition or explicitly set the '. + "No sequence found for '%s%s.%s', check the RDBMS table definition or explicitly set the ". "'sequence' for this column in %s", $schema ? "$schema." : '', $table, diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index bf5bb47..adfe403 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -398,7 +398,7 @@ if (DBIx::Class::_ENV_::DBICTEST) { for my $method (@{$method_dispatch->{unimplemented}}) { __PACKAGE__->meta->add_method($method, sub { my $self = shift; - $self->throw_exception("$method must not be called on ".(blessed $self).' objects'); + $self->throw_exception("$method() must not be called on ".(blessed $self).' objects'); }); } diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm index 82d3b6a..aec2ec1 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm @@ -239,7 +239,7 @@ sub _get_forced_pool { } elsif(my $replicant = $self->pool->replicants->{$forced_pool}) { return $replicant; } else { - $self->master->throw_exception("$forced_pool is not a named replicant."); + $self->master->throw_exception("'$forced_pool' is not a named replicant."); } } diff --git a/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm b/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm index ec83a33..6d48a4a 100644 --- a/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm +++ b/lib/DBIx/Class/Storage/DBI/UniqueIdentifier.pm @@ -90,7 +90,7 @@ sub _prefetch_autovalues { if (not defined $guid_method) { $self->throw_exception( - 'You must set new_guid on your storage. See perldoc ' + 'You must set new_guid() on your storage. See perldoc ' .'DBIx::Class::Storage::DBI::UniqueIdentifier' ); } diff --git a/t/storage/txn_scope_guard.t b/t/storage/txn_scope_guard.t index 739ed6c..c0cb347 100644 --- a/t/storage/txn_scope_guard.t +++ b/t/storage/txn_scope_guard.t @@ -24,7 +24,7 @@ use DBICTest; }); $guard->commit; - } qr/No such column made_up_column .*? at .*?\Q$fn\E line \d+/s, "Error propogated okay"; + } qr/No such column 'made_up_column' .*? at .*?\Q$fn\E line \d+/s, "Error propogated okay"; ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created");