=head1 NAME SuikaWiki::DB::Util --- SuikaWiki WikiDatabase: WikiDatabase modules common utilities =head1 DESCRIPTION This module provides some functions expected to be useful for most WikiDatabase implememtation modules. This module is part of SuikaWiki. =cut package SuikaWiki::DB::Util; use strict; our $VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; our $Err; =head1 FUNCTIONS =over 4 =item $err = SuikaWiki::DB::Util->error_handler () Returns error handler object (Message::Util::Error instance). =cut sub error_handler ($;%) { return $Err if $Err; my (undef, %opt) = @_; require Message::Util::Error; $Err = Message::Util::Error->new ({ ## Error level: ## - stop: cannot continue the operation (but other operations ## might be able to be performed) ## - fatal: cannot continue any operation anymore ## - warn: simple warning or harmless error ## - debug: debug message DB_OPEN => { level => 'fatal', description => q(Can't open database), }, DB_UNSUPPORTED_FORMAT => { level => 'stop', description => q(Unsupported format of database), }, DB_SAVE => { level => 'stop', description => q(Can't save database. Data might be lost), }, DB_CLOSE => { level => 'warn', description => q(Can't close database), }, LOCK_START => { level => 'fatal', description => q(Can't lock), }, LOCK_END => { level => 'warn', description => q(Can't unlock), }, KEY_INVALID_NAME => { level => 'stop', description => q(Invalid key name), }, KEY_INVALID_NS_NAME => { level => 'stop', description => q(Invalid key namespace), }, KEY_SAVE => { level => 'stop', description => q(Can't save to database), }, UNKNOWN => { level => 'fatal', description => 'Unknown error', }, -error_handler => $opt{-error_handler}, }); $Err; } =item $locker = SuikaWiki::DB::Util->new_lock ($options) Returns new locker object (SuikaWiki::DB::Util::Lock instance). =cut sub new_lock ($$) { require SuikaWiki::DB::Util::Lock; return SuikaWiki::DB::Util::Lock->new (%{$_[1]}); } =back =cut =head1 SEE ALSO C =head1 AUTHOR Wakaba . =head1 LICENSE Copyright AUTHOR 2003. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # $Date: 2003/08/06 02:54:40 $