Skip to content

Instantly share code, notes, and snippets.

@stigtsp
Last active April 9, 2022 21:08
Show Gist options
  • Save stigtsp/eee43074144cd1fa59b06e4ffd2c8f5f to your computer and use it in GitHub Desktop.
Save stigtsp/eee43074144cd1fa59b06e4ffd2c8f5f to your computer and use it in GitHub Desktop.
use v5.34;
use experimental qw(try signatures);
my @errors;
try {
something("/file-that-doesnt-exist");
} catch ($e) {
push @errors, $e;
}
if (@errors) {
say "Errors encountered during execution:";
say "- $_->{error}" for @errors;
exit(1);
}
sub something($file) {
unless (-f $file) {
die { error => "File $file does not exists" };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment