in reply to Can I catch a die from someone else's module?
G'day bartender1382,
I had a look in Spreadsheet::Read but can't find the "If a file cannot be found ..." message you reported. Perhaps it's not an error message but private feedback from the module's author. Regardless, I have no context for the die() or what it's reporting.
Having said that, I suspect what you want is eval. Compare the following two short pieces of code and their output.
Here's the type of scenario I think you're dealing with:
#!/usr/bin/env perl use strict; use warnings; package Module::That::Dies; sub die_here { die "RIP Module::That::Dies" } package main; Module::That::Dies::die_here(); print "main continues ...\n";
Output:
RIP Module::That::Dies at ./pm_11143055_trap_mod_errors.pl line 8.
Here's a modification of that code to do what I think you want:
#!/usr/bin/env perl use strict; use warnings; package Module::That::Dies; sub die_here { die "RIP Module::That::Dies" } package main; eval { Module::That::Dies::die_here(); 1; } or do { warn "Error from Module::That::Dies:\n$@\n"; }; print "main continues ...\n";
Output:
Error from Module::That::Dies: RIP Module::That::Dies at ./pm_11143055_trap_mod_errors.pl line 8. main continues ...
If that's not what you want, please provide more context for the problem to help us to help you.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can I catch a die from someone else's module?
by haukex (Archbishop) on Apr 18, 2022 at 20:07 UTC | |
|
Re^2: Can I catch a die from someone else's module?
by bartender1382 (Beadle) on Apr 19, 2022 at 18:41 UTC | |
by haukex (Archbishop) on Apr 19, 2022 at 18:57 UTC | |
by stevieb (Canon) on Apr 19, 2022 at 19:29 UTC | |
by kcott (Archbishop) on Apr 20, 2022 at 00:47 UTC | |
by kcott (Archbishop) on Apr 20, 2022 at 00:00 UTC | |
by perlfan (Parson) on May 02, 2022 at 01:39 UTC | |
by perlfan (Parson) on May 02, 2022 at 01:46 UTC |