Re: Carp and croak instead of warn and die
"Mr. Shawn H. Corey" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.pdfapi2 |
|---|---|
| Message-ID | <[email protected]> |
Jeffrey Ratcliffe wrote:
> It would be useful if carp and croak were used in all modules instead
> of warn and die, thus also displaying the line number of the calling
> program, as well as that of the library function.
>
> Whilst using die is acceptable if some batch process is being carried
> out, it is rather inconvenient for an application, where the whole
> thing crashes with no possibility to trap the error and the user has
> no opportunity to save work.
>
> Or am I missing something?
Yes.
eval { foobar };
if( $@ ){
# error trapped
}
This works regardless of if die, croak or exit was used. See `perldoc perlvar` and search for $@ and $SIG{expr} .
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by doing them."
Aristotle