Subject: | write_file() docs of error return |
Date: | Mon, 22 Apr 2019 10:19:44 +1000 |
To: | bug-File-Slurp [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
The docs of write_file() say
By default "write_file" returns 1 upon successfully writing the file
or "undef" if it encountered an error.
I read this as if I get return undef on error, whereas if I'm not
mistaken the default is croak on error. Would it say croak there and
then undef in other err_mode?
As a suggestion for the err_mode bit, perhaps a little table for the
benefit of skimming readers:
C<err_mode> option controls behaviour on error, either croak or return
undef.
"croak" (the default) croak() with descriptive message
"carp" carp() with message, return undef
"quiet" no messages etc, return undef
Take a look at L<Try::Tiny> or L<Syntax::Keyword::Try> to see how to
catch C<croak()> and similar exceptions.