use strict;
use warnings;
sub try (&;@) {};
sub catch (&;@){};
sub _ (&;@) {};
sub error_classes {
return map { $_ => bless {}, $_ } @_;
}
use constant {
error_classes qw(
FileNotFoundError
IsADirectoryError
)
};
try {
# your code here
} catch { FileNotFoundError } sub {
# handle exception
}, # extra comma needed
catch { IsADirectoryError } sub {
# handle exception
},
catch {
# all other types of exceptions
};
warn ('Should reach here');
try {
# your code here
} catch { FileNotFoundError }_{
# handle exception
} catch { IsADirectoryError }_{
# handle exception
} catch {
# all other types of exceptions
};
warn('Should reach here')
Hence the OP was wrong and needs to be corrected.
If anyone sees a way to avoid the trailing commas (or fat commas), please feel free to show ...
Otherwise, this break in symmetry is just "meh" ...
|