diff options
| author | fukachan <fukachan> | 2001-03-20 09:44:57 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-03-20 09:44:57 +0000 |
| commit | db1c5797b32dd075bcf455c5300ed82f9b22b8aa (patch) | |
| tree | cd9c9f2524dcf5a063f1345b53e8681451ab6d51 /fml/lib/File | |
| parent | 2198c4ce73b096d94ac6cbc591c86eca0a73b054 (diff) | |
| download | fml8-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/File')
| -rw-r--r-- | fml/lib/File/Errors.pm | 104 | ||||
| -rw-r--r-- | fml/lib/File/Sequence.pm | 6 | ||||
| -rw-r--r-- | fml/lib/File/SimpleLock.pm | 12 |
3 files changed, 8 insertions, 114 deletions
diff --git a/fml/lib/File/Errors.pm b/fml/lib/File/Errors.pm deleted file mode 100644 index 2980fd0c..00000000 --- a/fml/lib/File/Errors.pm +++ /dev/null @@ -1,104 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001 Ken'ichi Fukamachi -# All rights reserved. This program is free software; you can -# redistribute it and/or modify it under the same terms as Perl itself. -# -# $Id$ -# $FML$ -# - -package File::Errors; -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK); -use Carp; - -require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(error_reason error error_reset); - -=head1 NAME - -File::Errors - error handling utilities - -=head1 SYNOPSIS - -Consider C<Something> class module - - package Something; - use File::Errors qw(error_reason error error_reset); - - sub xxx - { - if something errors ... - $self->error_reason( error reason ); - } - -You use C<Something> module like this. - - use Something; - $obj = new Something; - $obj->xxx(); - unless ($obj->error) { $obj->do_somting( ...); }; - -=head1 DESCRIPTION - -simple utility functions to manipulate error messages. - -=head1 METHODS - -=head2 C<error_reason($message)> - -save $message as an error message. - -=head2 C<error()> - -return $message which is saved by C<error_reason($msg)>. - -=cut - - -sub error_reason -{ - my ($self, $mesg) = @_; - $self->{'_error_reason'} = $mesg; -} - - -sub error -{ - my ($self, $args) = @_; - return $self->{'_error_reason'}; -} - - -sub error_reset -{ - my ($self, $args) = @_; - my $msg = $self->{'_error_reason'}; - undef $self->{'_error_reason'} if defined $self->{'_error_reason'}; - undef $self->{'_error_action'} if defined $self->{'_error_action'}; - return $msg; -} - - -=head1 AUTHOR - -Ken'ichi Fukamachi - -=head1 COPYRIGHT - -Copyright (C) 2001 Ken'ichi Fukamachi - -All rights reserved. This program is free software; you can -redistribute it and/or modify it under the same terms as Perl itself. - -=head1 HISTORY - -File::Errors appeared in fml5 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/File/Sequence.pm b/fml/lib/File/Sequence.pm index 5cfc90e6..d770fa5f 100644 --- a/fml/lib/File/Sequence.pm +++ b/fml/lib/File/Sequence.pm @@ -12,7 +12,7 @@ package File::Sequence; use strict; use vars qw(@ISA @EXPORT @EXPORT_OK); use Carp; -use File::Errors qw(error_reason error error_reset); +use ErrorMessages::Status qw(error_set error error_reset); =head1 NAME @@ -96,7 +96,7 @@ sub increment_id my $seq_file = $file || $self->{ _sequence_file }; unless ($seq_file) { - $self->error_reason("the sequence file is not specified"); + $self->error_set("the sequence file is not specified"); return 0; }; @@ -115,7 +115,7 @@ sub increment_id $rh->close; } else { - $self->error_reason("cannot open the sequence file"); + $self->error_set("cannot open the sequence file"); return 0; } diff --git a/fml/lib/File/SimpleLock.pm b/fml/lib/File/SimpleLock.pm index ab789d77..3245e81b 100644 --- a/fml/lib/File/SimpleLock.pm +++ b/fml/lib/File/SimpleLock.pm @@ -11,9 +11,7 @@ package File::SimpleLock; use vars qw(%LockedFileHandle %FileIsLocked @ISA $Error); use strict; use Carp; -use File::Errors; - -@ISA = qw(File::Errors); +use ErrorMessages::Status qw(error_set error error_reset); =head1 NAME @@ -96,7 +94,7 @@ sub _simple_flock eval q{ $r = flock($fh, &LOCK_EX); }; - $self->error_reason($@) if $@; + $self->error_set($@) if $@; if ($r) { $FileIsLocked{ $file } = 1; @@ -104,7 +102,7 @@ sub _simple_flock } } else { - $self->error_reason("cannot open $file"); + $self->error_set("cannot open $file"); } return 0; @@ -124,7 +122,7 @@ sub _simple_funlock eval q{ $r = flock($fh, &LOCK_UN); }; - $self->error_reason($@) if $@; + $self->error_set($@) if $@; if ($r) { delete $FileIsLocked{ $file }; @@ -139,7 +137,7 @@ sub _simple_funlock =head1 SEE ALSO L<FileHandle>, -L<File::Errors>, +L<ErrorMessages::Status>, =head1 AUTHOR |
