From addb2f4f7e0e1304f5dfb9f9679efe8548c8472d Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 18 Jul 2007 17:43:10 +0000 Subject: * replaces most occurrences of confess() with croak(), as that is less noisy. Confess()-ing can still be triggered by specifying --debug-confess on the commandline. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1249 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/MetaDB/Base.pm | 2 +- config-db/OpenSLX/MetaDB/CSV.pm | 18 +++++++++--------- config-db/OpenSLX/MetaDB/DBI.pm | 30 +++++++++++++++--------------- config-db/OpenSLX/MetaDB/mysql.pm | 11 ++++++----- 4 files changed, 31 insertions(+), 30 deletions(-) (limited to 'config-db') diff --git a/config-db/OpenSLX/MetaDB/Base.pm b/config-db/OpenSLX/MetaDB/Base.pm index 3f03fbed..7c4a8f3b 100644 --- a/config-db/OpenSLX/MetaDB/Base.pm +++ b/config-db/OpenSLX/MetaDB/Base.pm @@ -269,7 +269,7 @@ OpenSLX::MetaDB::Base - the base class for all MetaDB drivers my $superVersion = $OpenSLX::MetaDB::Base::VERSION; if ($superVersion < $VERSION) { - confess _tr('Unable to load module <%s> (Version <%s> required)', + croak _tr('Unable to load module <%s> (Version <%s> required)', 'OpenSLX::MetaDB::Base', $VERSION); } diff --git a/config-db/OpenSLX/MetaDB/CSV.pm b/config-db/OpenSLX/MetaDB/CSV.pm index 0ef9ab93..fbd2c7ec 100644 --- a/config-db/OpenSLX/MetaDB/CSV.pm +++ b/config-db/OpenSLX/MetaDB/CSV.pm @@ -75,10 +75,10 @@ sub start_transaction my $dbh = $self->{'dbh'}; my $lockFile = "$dbh->{'f_dir'}/transaction-lock"; sysopen(TRANSFILE, $lockFile, O_RDWR | O_CREAT) - or confess _tr(q[Can't open transaction-file '%s' (%s)], $lockFile, $!); + or croak _tr(q[Can't open transaction-file '%s' (%s)], $lockFile, $!); $self->{"transaction-lock"} = *TRANSFILE; flock(TRANSFILE, LOCK_EX) - or confess _tr(q[Can't lock transaction-file '%s' (%s)], $lockFile, $!); + or croak _tr(q[Can't lock transaction-file '%s' (%s)], $lockFile, $!); return; } @@ -87,7 +87,7 @@ sub commit_transaction my $self = shift; if (!defined $self->{"transaction-lock"}) { - confess _tr(q[no open transaction-lock found!]); + croak _tr(q[no open transaction-lock found!]); } close($self->{"transaction-lock"}); $self->{"transaction-lock"} = undef; @@ -99,7 +99,7 @@ sub rollback_transaction my $self = shift; if (!defined $self->{"transaction-lock"}) { - confess _tr(q[no open transaction-lock found!]); + croak _tr(q[no open transaction-lock found!]); } close($self->{"transaction-lock"}); $self->{"transaction-lock"} = undef; @@ -117,9 +117,9 @@ sub generateNextIdForTable my $dbh = $self->{'dbh'}; my $idFile = "$dbh->{'f_dir'}/id-$table"; sysopen(IDFILE, $idFile, O_RDWR | O_CREAT) - or confess _tr(q[Can't open ID-file '%s' (%s)], $idFile, $!); + or croak _tr(q[Can't open ID-file '%s' (%s)], $idFile, $!); flock(IDFILE, LOCK_EX) - or confess _tr(q[Can't lock ID-file '%s' (%s)], $idFile, $!); + or croak _tr(q[Can't lock ID-file '%s' (%s)], $idFile, $!); my $nextID = ; if (!$nextID) { # no ID information available, we protect against users having @@ -134,11 +134,11 @@ sub generateNextIdForTable $nextID = 1 + $maxID; } seek(IDFILE, 0, 0) - or confess _tr(q[Can't to seek ID-file '%s' (%s)], $idFile, $!); + or croak _tr(q[Can't to seek ID-file '%s' (%s)], $idFile, $!); truncate(IDFILE, 0) - or confess _tr(q[Can't truncate ID-file '%s' (%s)], $idFile, $!); + or croak _tr(q[Can't truncate ID-file '%s' (%s)], $idFile, $!); print IDFILE $nextID + 1 - or confess _tr(q[Can't update ID-file '%s' (%s)], $idFile, $!); + or croak _tr(q[Can't update ID-file '%s' (%s)], $idFile, $!); close(IDFILE); return $nextID; diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm index 470fa5c7..27d493f6 100644 --- a/config-db/OpenSLX/MetaDB/DBI.pm +++ b/config-db/OpenSLX/MetaDB/DBI.pm @@ -87,10 +87,10 @@ sub _doSelect vlog(3, _trim($sql)); my $sth = $dbh->prepare($sql) or - confess _tr(q[Can't prepare SQL-statement <%s> (%s)], $sql, $dbh->errstr); + croak _tr(q[Can't prepare SQL-statement <%s> (%s)], $sql, $dbh->errstr); $sth->execute() or - confess _tr(q[Can't execute SQL-statement <%s> (%s)], $sql, $dbh->errstr); + croak _tr(q[Can't execute SQL-statement <%s> (%s)], $sql, $dbh->errstr); my (@vals, $row); while ($row = $sth->fetchrow_hashref()) { @@ -385,10 +385,10 @@ sub _doInsert my $sql = "INSERT INTO $table ( $cols ) VALUES ( $values )"; vlog(3, $sql); my $sth = $dbh->prepare($sql) - or confess _tr(q[Can't insert into table <%s> (%s)], $table, + or croak _tr(q[Can't insert into table <%s> (%s)], $table, $dbh->errstr); $sth->execute() - or confess _tr(q[Can't insert into table <%s> (%s)], $table, + or croak _tr(q[Can't insert into table <%s> (%s)], $table, $dbh->errstr); if (!$ignoreIDs && !defined $valRow->{id}) { # id has not been pre-specified, we need to fetch it from DB: @@ -422,10 +422,10 @@ sub _doDelete } vlog(3, $sql); my $sth = $dbh->prepare($sql) - or confess _tr(q[Can't delete from table <%s> (%s)], $table, + or croak _tr(q[Can't delete from table <%s> (%s)], $table, $dbh->errstr); $sth->execute() - or confess _tr(q[Can't delete from table <%s> (%s)], $table, + or croak _tr(q[Can't delete from table <%s> (%s)], $table, $dbh->errstr); } return 1; @@ -459,9 +459,9 @@ sub _doUpdate } vlog(3, $sql); my $sth = $dbh->prepare($sql) - or confess _tr(q[Can't update table <%s> (%s)], $table, $dbh->errstr); + or croak _tr(q[Can't update table <%s> (%s)], $table, $dbh->errstr); $sth->execute() - or confess _tr(q[Can't update table <%s> (%s)], $table, $dbh->errstr); + or croak _tr(q[Can't update table <%s> (%s)], $table, $dbh->errstr); } return 1; } @@ -746,7 +746,7 @@ sub _convertColDescrsToDBNativeString # convert each column description into database native format # (e.g. convert 'name:s.45' to 'name char(45)'): if (!m[^\s*(\S+?)\s*:\s*(\S+?)\s*$]) { - confess _tr('UnknownDbSchemaColumnDescr', $_); + croak _tr('UnknownDbSchemaColumnDescr', $_); } "$1 " . $self->schemaConvertTypeDescrToNative($2); } @$colDescrs; @@ -762,7 +762,7 @@ sub _convertColDescrsToColNames # convert each column description into database native format # (e.g. convert 'name:s.45' to 'name char(45)'): if (!m[^\s*(\S+?)\s*:.+$]) { - confess _tr('UnknownDbSchemaColumnDescr', $_); + croak _tr('UnknownDbSchemaColumnDescr', $_); } $1; } @$colDescrs; @@ -807,7 +807,7 @@ sub schemaConvertTypeDescrToNative } elsif ($typeDescr =~ m[^s\.(\d+)$]i) { return "varchar($1)"; } else { - confess _tr('UnknownDbSchemaTypeDescr', $typeDescr); + croak _tr('UnknownDbSchemaTypeDescr', $typeDescr); } } @@ -825,7 +825,7 @@ sub schemaAddTable my $sql = "CREATE TABLE $table ($colDescrString)"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't create table <%s> (%s)], $table, $dbh->errstr); + or croak _tr(q[Can't create table <%s> (%s)], $table, $dbh->errstr); if (defined $initialVals) { my $ignoreIDs = ($colDescrString !~ m[\bid\b]); # don't care about IDs if there's no 'id' column in this table @@ -845,7 +845,7 @@ sub schemaDropTable my $sql = "DROP TABLE $table"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't drop table <%s> (%s)], $table, $dbh->errstr); + or croak _tr(q[Can't drop table <%s> (%s)], $table, $dbh->errstr); return; } @@ -870,14 +870,14 @@ sub schemaRenameTable my $sql = "CREATE TABLE $newTable ($colDescrString)"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't create table <%s> (%s)], $oldTable, $dbh->errstr); + or croak _tr(q[Can't create table <%s> (%s)], $oldTable, $dbh->errstr); my $colNamesString = $self->_convertColDescrsToColNamesString($colDescrs); my @dataRows = $self->_doSelect("SELECT $colNamesString FROM $oldTable"); $self->_doInsert($newTable, \@dataRows); $sql = "DROP TABLE $oldTable"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't drop table <%s> (%s)], $oldTable, $dbh->errstr); + or croak _tr(q[Can't drop table <%s> (%s)], $oldTable, $dbh->errstr); return; } diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm index 03272331..661b744d 100644 --- a/config-db/OpenSLX/MetaDB/mysql.pm +++ b/config-db/OpenSLX/MetaDB/mysql.pm @@ -68,8 +68,9 @@ sub schemaConvertTypeDescrToNative } elsif ($typeDescr =~ m[^s\.(\d+)$]i) { return "varchar($1)"; } else { - confess _tr('UnknownDbSchemaTypeDescr', $typeDescr); + croak _tr('UnknownDbSchemaTypeDescr', $typeDescr); } + return; } sub schemaRenameTable @@ -85,7 +86,7 @@ sub schemaRenameTable my $sql = "ALTER TABLE $oldTable RENAME TO $newTable"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr); + or croak _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr); return; } @@ -107,7 +108,7 @@ sub schemaAddColumns my $sql = "ALTER TABLE $table $addClause"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't add columns to table <%s> (%s)], $table, + or croak _tr(q[Can't add columns to table <%s> (%s)], $table, $dbh->errstr); # if default values have been provided, we apply them now: if (defined $newColDefaultVals) { @@ -133,7 +134,7 @@ sub schemaDropColumns my $sql = "ALTER TABLE $table $dropClause"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't drop columns from table <%s> (%s)], $table, + or croak _tr(q[Can't drop columns from table <%s> (%s)], $table, $dbh->errstr); return; } @@ -158,7 +159,7 @@ sub schemaChangeColumns my $sql = "ALTER TABLE $table $changeClause"; vlog(3, $sql); $dbh->do($sql) - or confess _tr(q[Can't change columns in table <%s> (%s)], $table, + or croak _tr(q[Can't change columns in table <%s> (%s)], $table, $dbh->errstr); return; } -- cgit v1.2.3-55-g7522