in reply to Capture Elasticsearch Scroll Error
Thanks for updating the post.
You might like to look at Try::Tiny.
It puts the error in $_.
Here's a demo:
Output:$ perl -Mstrict -Mwarnings -MTry::Tiny -E ' sub my_func { my $num = shift; say "=" x 20; say "Num: $num"; try { say( 1 / $num ); } catch { say "Your error message here."; say "Original error:"; say ">" . $_ . "<"; }; # semicolon say "Not dead"; } my_func( $_ ) for ( 0, 1 ); say "=" x 20; '
==================== Num: 0 Your error message here. Original error: >Illegal division by zero at -e line 7. < Not dead ==================== Num: 1 1 Not dead ====================
Hope this helps
|
|---|