Subject: | allow changing of boolean value |
Date: | Mon, 28 May 2012 18:30:29 -0500 |
To: | bugs-exception-base [...] rt.cpan.org |
From: | Caleb Cushing <xenoterracide [...] gmail.com> |
I understand the reason for making the exception always return true in
boolean context but I think it would be nice to change that in
new/throw perhaps with the key bool. the reason being is it'd be nice
to write.
use Exception::Base;
sub is_valid {
my $self = shift;
# obviously put actual checks
return Exception::Base->new( message => 'is_valid', boolean => 1 );
}
sub do_something {
my $self = shift;
if ( my $result = $self->is_valid ) { # won't throw if "valid"
$result->throw;
}
}
obviously this is kind of possible with a little extra magic now.
--
Caleb Cushing
http://xenoterracide.com