D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error::Simple -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
-text at D:\UseNet\clpmisc\err.pl line 8.
Now, of course, the error message should have been "Oops!".
On the other hand:
D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
Oops!
Hmmmmm ...
Now, Error::Simple overrides Error->new but not Error->throw.
Show quoted text
>> 265 sub new {
>> 266 my $self = shift;
>> 267 my $text = "" . shift;
This causes the overloaded stringification operator to be invoked which
adds the "at D:\UseNet\clpmisc\err.pl line 8." at the end of the error
message above.
Show quoted text>> 268 my $value = shift;
>> 269 my(@args) = ();
The problem is, Error::Simple->new ends with:
$self->SUPER::new(-text => $text, @args);
whereas it should be
$self->SUPER::new(-text => $value, @args);
After making that change in Error.pm:
D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error::Simple -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
Oops! at D:\UseNet\clpmisc\err.pl line 8.