At
view release on metacpan or search on metacpan
lib/At/Error.pm view on Meta::CPAN
# TODO: What should I do with description? Nothing?
ADJUST {
my $i = 0; # Skip one
while ( my %i = Carp::caller_info( ++$i ) ) {
next if $i{pack} eq __CLASS__;
push @stack, \%i;
}
}
method throw() {
my ( undef, $file, $line ) = caller();
my $msg = join "\n\t", sprintf( qq[%s at %s line %d], $message, $file, $line ),
map { sprintf q[%s called at %s line %d], $_->{sub_name}, $_->{file}, $_->{line} } @stack;
$fatal ? die "$msg\n" : warn "$msg\n";
}
sub register( $class, $fatal //= 0 ) {
my ($from) = caller;
no strict 'refs';
*{ $from . '::' . $class } = sub ( $message, $description //= '' ) {
($class)->new( message => $message, description => $description, fatal => $fatal );
( run in 0.283 second using v1.01-cache-2.11-cpan-b61123c0432 )