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 +++++----- installer/OpenSLX/OSExport/BlockDevice/Base.pm | 2 +- installer/OpenSLX/OSExport/Distro/Base.pm | 2 +- installer/OpenSLX/OSExport/FileSystem/Base.pm | 2 +- installer/OpenSLX/OSSetup/Distro/Base.pm | 1 - installer/OpenSLX/OSSetup/MetaPackager/Base.pm | 1 - installer/OpenSLX/OSSetup/Packager/Base.pm | 2 +- lib/OpenSLX/ConfigFolder.pm | 1 - lib/OpenSLX/Utils.pm | 1 - 12 files changed, 35 insertions(+), 38 deletions(-) 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; } diff --git a/installer/OpenSLX/OSExport/BlockDevice/Base.pm b/installer/OpenSLX/OSExport/BlockDevice/Base.pm index ef59f86b..3650e8be 100644 --- a/installer/OpenSLX/OSExport/BlockDevice/Base.pm +++ b/installer/OpenSLX/OSExport/BlockDevice/Base.pm @@ -18,7 +18,7 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); +use OpenSLX::Basics; ################################################################################ ### interface methods diff --git a/installer/OpenSLX/OSExport/Distro/Base.pm b/installer/OpenSLX/OSExport/Distro/Base.pm index 67d18951..29659f09 100644 --- a/installer/OpenSLX/OSExport/Distro/Base.pm +++ b/installer/OpenSLX/OSExport/Distro/Base.pm @@ -19,7 +19,7 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); +use OpenSLX::Basics; ################################################################################ ### interface methods diff --git a/installer/OpenSLX/OSExport/FileSystem/Base.pm b/installer/OpenSLX/OSExport/FileSystem/Base.pm index 0822c458..9ae263f9 100644 --- a/installer/OpenSLX/OSExport/FileSystem/Base.pm +++ b/installer/OpenSLX/OSExport/FileSystem/Base.pm @@ -18,7 +18,7 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); +use OpenSLX::Basics; ################################################################################ ### interface methods diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm index 0cea7ab6..09323b52 100644 --- a/installer/OpenSLX/OSSetup/Distro/Base.pm +++ b/installer/OpenSLX/OSSetup/Distro/Base.pm @@ -18,7 +18,6 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); use File::Basename; use OpenSLX::Basics; diff --git a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm index 16aa290d..d5b42f20 100644 --- a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm +++ b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm @@ -18,7 +18,6 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); use OpenSLX::Basics; ################################################################################ diff --git a/installer/OpenSLX/OSSetup/Packager/Base.pm b/installer/OpenSLX/OSSetup/Packager/Base.pm index 34927821..3aa8921e 100644 --- a/installer/OpenSLX/OSSetup/Packager/Base.pm +++ b/installer/OpenSLX/OSSetup/Packager/Base.pm @@ -18,7 +18,7 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version -use Carp qw(confess); +use OpenSLX::Basics; ################################################################################ ### interface methods diff --git a/lib/OpenSLX/ConfigFolder.pm b/lib/OpenSLX/ConfigFolder.pm index de2df73f..99289881 100644 --- a/lib/OpenSLX/ConfigFolder.pm +++ b/lib/OpenSLX/ConfigFolder.pm @@ -30,7 +30,6 @@ $VERSION = 1.01; ################################################################################ ### Module implementation ################################################################################ -use Carp; use OpenSLX::Basics; use OpenSLX::Utils; diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index 22555df3..d23eb6e8 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -29,7 +29,6 @@ $VERSION = 1.01; ################################################################################ ### Module implementation ################################################################################ -use Carp; use File::Basename; use OpenSLX::Basics; -- cgit v1.2.3-55-g7522