Subject: Developers of Sympa
List archive
- From: Marc Chantreux <address@concealed>
- To: IKEDA Soji <address@concealed>
- Cc: address@concealed
- Subject: Re: [sympa-developpers] Why autodie?
- Date: Tue, 27 Feb 2018 09:09:38 +0100
hello Soji,
On Thu, Feb 22, 2018 at 11:42:28PM +0900, IKEDA Soji wrote:
> >> So as a typical use case when I open a file and it doesn't exist with
> >> autodie?
> >
> >> if (open (...)) {
> >> found ... proceed
> >> } elsif ( "File not found" ) {
> >> sure, we look elsewhere
> >> } else {
> >> log the error and handle the problem
> >> }
trying to write an example for this case, i spot that $! doesn't
survive to the eval block so it's lost if you want to do something in
the catch block for example.
so when you want to explicitly handle error, the best way seems to be
no autodie
once again: this is very similar to
use strict
to make perl care about errors for you and
no strict
when you think you will exactly know what to do
use Sympatic;
use autodie;
fun open_r ( $path ) {
no autodie;
my $fh;
return $fh if
open $fh
, '<'
, $path
return another_path
if $!{ENOENT};
handle_the_problem;
}
-
Re: [sympa-developpers] Why autodie?
, (continued)
- Re: [sympa-developpers] Why autodie?, Soji Ikeda, 02/22/2018
- Re: [sympa-developpers] Why autodie?, David Verdin, 02/22/2018
- Re: [sympa-developpers] Why autodie?, Marc Chantreux, 02/22/2018
- Re: [sympa-developpers] Why autodie?, IKEDA Soji, 02/24/2018
- Re: [sympa-developpers] Why autodie?, Stefan Hornburg (Racke), 02/24/2018
-
Re: [sympa-developpers] Why autodie?,
Marc Chantreux, 02/22/2018
-
Re: [sympa-developpers] Why autodie?,
IKEDA Soji, 02/22/2018
- Re: [sympa-developpers] Why autodie?, Marc Chantreux, 02/27/2018
-
Re: [sympa-developpers] Why autodie?,
IKEDA Soji, 02/22/2018
- Re: [sympa-developpers] Why autodie?, David Verdin, 02/20/2018
Archive powered by MHonArc 2.6.19+.