File: TestThrower.pm

package info (click to toggle)
libfailures-perl 0.004-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 192 kB
  • sloc: perl: 298; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 477 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use 5.008001;
use strict;
use warnings;

package TestThrower;

use Exporter;
our @ISA    = qw/Exporter/;
our @EXPORT = qw(
  deep_throw
);
our @CARP_NOT = qw/Foo/;

sub deep_throw { Foo::foo(@_) }

package Foo;

our @CARP_NOT = qw/Bar/;

sub foo { Bar::bar(@_) }

package Bar;

our @CARP_NOT = qw/Baz/;

sub bar { Baz::baz(@_) }

package Baz;

sub baz {
    my ( $class, $msg, $trace_method ) = @_;
    $class->throw( { msg => $msg, trace => failure->$trace_method } );
}

1;