> >I am using a module that does use Carp; and you
> >can specify whther you want croak or carp on an error
> >Which is cool. But there is no way to specify anythign
> >else besides those two.
> >
> >What I'd like to do is get any errors into a variable:
> 
> You want Carp::shortmess().
> 
>   perldoc Carp

That would require modifying the module which I want to avoid.
Inside a function of another package it calls either carp or croak.
I'd like to get that error into a variable I can use and not die 
or warn from croak or carp.

my $err = '';
$SIG{__WARN__} = sub { $err = shift; }
$SIG{__DIE__} = sub {$err = shift; }

my $res = function_that_carps_or_croaks_that_i_cant_modify();
if($err) { handle_error_my_way_instead_of_simply_carping_or_croaking($err); }

$SIG{__WARN__} = ''; # or is undef or delete better??
$SIG{__DIE__} = ''; # or is undef or delete better??

That works like a charm but it does not work with $SIG{__DIE__} for some reason.
It still just croaks as usual. Any ideas?

> 
> -- 
> Jeff "japhy" Pinyan      [EMAIL PROTECTED]  

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to