summaryrefslogtreecommitdiff
path: root/fml/lib/IO
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-03-20 09:44:57 +0000
committerfukachan <fukachan>2001-03-20 09:44:57 +0000
commitdb1c5797b32dd075bcf455c5300ed82f9b22b8aa (patch)
treecd9c9f2524dcf5a063f1345b53e8681451ab6d51 /fml/lib/IO
parent2198c4ce73b096d94ac6cbc591c86eca0a73b054 (diff)
downloadfml8-db1c5797b32dd075bcf455c5300ed82f9b22b8aa.tar.gz
fml8-db1c5797b32dd075bcf455c5300ed82f9b22b8aa.tar.bz2
fml8-db1c5797b32dd075bcf455c5300ed82f9b22b8aa.zip
rewritten to ErrorMessages::Status module for unification of error
buffer handling.
Diffstat (limited to 'fml/lib/IO')
-rw-r--r--fml/lib/IO/Adapter/Array.pm3
-rw-r--r--fml/lib/IO/Adapter/DBI.pm27
-rw-r--r--fml/lib/IO/Adapter/File.pm9
-rw-r--r--fml/lib/IO/Adapter/MySQL.pm4
-rw-r--r--fml/lib/IO/MapAdapter.pm36
5 files changed, 20 insertions, 59 deletions
diff --git a/fml/lib/IO/Adapter/Array.pm b/fml/lib/IO/Adapter/Array.pm
index acc60775..04b6970d 100644
--- a/fml/lib/IO/Adapter/Array.pm
+++ b/fml/lib/IO/Adapter/Array.pm
@@ -13,6 +13,7 @@ package IO::Adapter::Array;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
+use ErrorMessages::Status qw(error_set error error_reset);
=head1 NAME
@@ -84,7 +85,7 @@ sub open
my $r_array = $self->{ _array_reference};
if ($flag ne 'r') {
- $self->_error_reason("Error: type=$self->{_type} is read only.");
+ $self->error_set("Error: type=$self->{_type} is read only.");
return undef;
}
diff --git a/fml/lib/IO/Adapter/DBI.pm b/fml/lib/IO/Adapter/DBI.pm
index 527e9529..50f5e2b8 100644
--- a/fml/lib/IO/Adapter/DBI.pm
+++ b/fml/lib/IO/Adapter/DBI.pm
@@ -11,6 +11,7 @@ package IO::Adapter::DBI;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
+use ErrorMessages::Status qw(error_set error error_reset);
=head1 NAME
@@ -69,12 +70,12 @@ sub execute
return $res;
}
else {
- $self->error_reason( $DBI::errstr );
+ $self->error_set( $DBI::errstr );
return undef;
}
}
else {
- $self->error_reason( $DBI::errstr );
+ $self->error_set( $DBI::errstr );
return undef;
}
}
@@ -105,7 +106,7 @@ sub open
# try to connect
my $dbh = DBI->connect($dsn, $user, $password);
unless (defined $dbh) {
- $self->error_reason( $DBI::errstr );
+ $self->error_set( $DBI::errstr );
return undef;
}
@@ -130,24 +131,4 @@ sub close
}
-=head2 C<error_reason($mesg)>
-
-=head2 C<error()>
-
-=cut
-
-sub error_reason
-{
- my ($self, $mesg) = @_;
- $self->{ _error } = $mesg;
-}
-
-
-sub error
-{
- my ($self) = @_;
- return $self->{ _error };
-}
-
-
1;
diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm
index b0378933..cd647134 100644
--- a/fml/lib/IO/Adapter/File.pm
+++ b/fml/lib/IO/Adapter/File.pm
@@ -13,6 +13,7 @@ package IO::Adapter::File;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
+use ErrorMessages::Status qw(error_set error error_reset);
=head1 NAME
@@ -106,7 +107,7 @@ sub _read_open
return $fh;
}
else {
- $self->_error_reason("Error: cannot open file=$file flag=$flag");
+ $self->error_set("Error: cannot open file=$file flag=$flag");
return undef;
}
}
@@ -261,7 +262,7 @@ sub add
$fh->close;
}
else {
- $self->_error_reason("Error: cannot open file=$self->{ _file }");
+ $self->error_set("Error: cannot open file=$self->{ _file }");
return undef;
}
@@ -295,7 +296,7 @@ sub delete
$wh->close;
}
else {
- $self->_error_reason("Error: cannot open file=$self->{ _file }");
+ $self->error_set("Error: cannot open file=$self->{ _file }");
return undef;
}
}
@@ -330,7 +331,7 @@ sub replace
$wh->close;
}
else {
- $self->_error_reason("Error: cannot open file=$self->{ _file }");
+ $self->error_set("Error: cannot open file=$self->{ _file }");
return undef;
}
}
diff --git a/fml/lib/IO/Adapter/MySQL.pm b/fml/lib/IO/Adapter/MySQL.pm
index 28a93433..cbc97a96 100644
--- a/fml/lib/IO/Adapter/MySQL.pm
+++ b/fml/lib/IO/Adapter/MySQL.pm
@@ -94,7 +94,7 @@ sub configure
$me->{ _schema } = $pkg;
}
else {
- error_reason($self, $@);
+ error_set($self, $@);
return undef;
}
}
@@ -140,7 +140,7 @@ sub get_next_value
join(" ", @row);
}
else {
- $self->error_reason( $DBI::errstr );
+ $self->error_set( $DBI::errstr );
undef;
}
}
diff --git a/fml/lib/IO/MapAdapter.pm b/fml/lib/IO/MapAdapter.pm
index 1688b910..7f8d5e36 100644
--- a/fml/lib/IO/MapAdapter.pm
+++ b/fml/lib/IO/MapAdapter.pm
@@ -12,6 +12,7 @@ package IO::MapAdapter;
use vars qw(@ISA @ORIG_ISA $FirstTime);
use strict;
use Carp;
+use ErrorMessages::Status qw(error_set error error_reset);
BEGIN {}
END {}
@@ -150,7 +151,7 @@ sub new
}
else {
my $s = "IO::MapAdapter::new: map='$map' is unknown.";
- _error_reason($me, $s);
+ error_set($me, $s);
}
}
@@ -160,7 +161,7 @@ sub new
eval qq{ require $pkg; $pkg->import();};
$pkg->configure($me, $args) if $pkg->can('configure');
- _error_reason($me, $@) if $@;
+ error_set($me, $@) if $@;
return bless $me, $type;
}
@@ -201,7 +202,7 @@ sub open
$self->SUPER::open( { flag => $flag } );
}
else {
- $self->_error_reason("Error: type=$self->{_type} is unknown type.");
+ $self->error_set("Error: type=$self->{_type} is unknown type.");
}
}
@@ -272,7 +273,7 @@ sub add
$self->SUPER::add($address);
}
else {
- $self->_error_reason("Error: add() method is not supported.");
+ $self->error_set("Error: add() method is not supported.");
undef;
}
}
@@ -290,7 +291,7 @@ sub delete
$self->SUPER::delete($regexp);
}
else {
- $self->_error_reason("Error: delete() method is not supported.");
+ $self->error_set("Error: delete() method is not supported.");
undef;
}
}
@@ -308,7 +309,7 @@ sub replace
$self->SUPER::replace($regexp, $value);
}
else {
- $self->_error_reason("Error: replace() method is not supported.");
+ $self->error_set("Error: replace() method is not supported.");
undef;
}
}
@@ -327,29 +328,6 @@ sub DESTROY
}
-# Descriptions: log the error message in the object
-# internal use fucntion.
-# Arguments: $self $mesg
-# $mesg is the error message string.
-# Side Effects: $self->{ _error_reason } is set to $mesg.
-# Return Value: $mesg
-sub _error_reason
-{
- my ($self, $mesg) = @_;
- $self->{ _error_reason } = $mesg;
-}
-
-
-# Descriptions: return the error message
-# Arguments: $self
-# Side Effects: none
-# Return Value: error message
-sub error
-{
- my ($self) = @_;
- return $self->{ _error_reason };
-}
-
=head2
=item C<error()>