# Trait for Handle Excepions via virtuell Exception Classes use strict; use warnings; use Devel::StackTrace; # FW Methode sub throw{ my $self = shift; my $class = shift; my $msg = shift; eval{ die "$msg\n" }; chomp $@; $self->{exceptions}{$class} = { error => $@, trace => Devel::StackTrace->new }; die "$msg\n"; } # FW Methode sub caught{ my $self = shift; my $class = shift; bless $self->{exceptions}{$class}, __PACKAGE__; } # EX Methode sub error{ my $self = shift; $self->{error}; } # EX Methode sub trace{ my $self = shift; $self->{trace}->as_string; } 1;