Subject: | Can't clear error state |
Date: | Fri, 26 Apr 2019 10:40:24 -0400 |
To: | bug-Net-IMAP-Simple [...] rt.cpan.org |
From: | tlhackque <tlhackque [...] yahoo.com> |
Once an error happens, errstr() will return it forever; there is no
documented method for clearing the error state short of closing the
mailbox and re-connecting with a new object.
This is inconvenient, to say the least.
Either or both of the following should happen:
a) At the start of every operation, set $this->{_errstr} = '';
b) Provide a method along the lines of:
sub clearerr {
my( $self ) = @_;
$self->{_errstr} = '';
return;
}
There are arguments for both:
a) makes errstr() report on (only) the current operation
b) will return the last error in a series of operations, until the
application confirms that it saw it.
An alternative is for errstr to clear {_errstr} after returning the
error, which is simpler for everyone concerned, but would be a break
with existing behavior... It's not clear why anyone would call errstr
twice for the same event (perhaps logging to a file and STDERR?), but
users do the strangest things...
sub errstr {
my $err = $_[0]->{_errstr};
$_[0]->{_errstr} = '';
return $err;
}