use warnings; use Scalar::Util "blessed"; { package Error::Base; sub new { my($class, $str, @rest) = @_; my %o = (str => $str, @rest); # you may store backtrace info too bless \%o, $class; } use overload q/""/ => "strify"; sub strify { my($self) = @_; $$self{str} . "\n"; # you may append a user-readable form of the backtrace } sub crash { my($self, @rest) = @_; die $self->new(@rest); } } my $wt = -140; if ($wt < 0) { Error::Base->crash("creature weight negative", negative_creature_weight => 1, creature_name => "dragon", creature_weight => -140, ); } __END__