use strict; use warnings; package RemoteException; use Error; use base qw(Error); use overload ('""' => 'stringify'); sub new { my $self = shift; my $text = "" . shift; my @args = (); local $Error::Depth = $Error::Depth + 1; local $Error::Debug = 1; # Enables storing of stacktrace $self->SUPER::new(-text => $text, @args); } 1; package WineException; use base qw(RemoteException); sub h{ print "heheh\n"; } 1; package DeployException; use base qw(RemoteException); sub h{ print "heheh\n"; } 1; package BeerException; use base qw(RemoteException); sub h{ print "heheh\n"; } 1;