File: grinnz-die-in-die.t

package info (click to toggle)
libpoe-perl 2%3A1.3700-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 1,980 kB
  • sloc: perl: 22,867; makefile: 9
file content (44 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
43
44
#!/usr/bin/env perl

use strict;
use warnings;

use Test::More tests => 3;
use POE;

POE::Session->create(
	inline_states => {
		_start => sub {
			$_[KERNEL]->sig(DIE => 'sig_DIE');
			die 'original error';
		},
		sig_DIE => sub {
			my $exception = $_[ARG1];
			my $event = $exception->{'event'};
			my $error = $exception->{'error_str'};

			chomp $error;

			is($event, '_start', "die in $event caught");

			die 'error in error handler';

			# The die() above bypasses this call.
			POE::Kernel->sig_handled();
		},
	}
);

eval {
	POE::Kernel->run();
};

like(
	$@, qr/original error/,
	"run() rethrown exception contains original error"
);

like(
	$@, qr/error in error handler/,
	"run() rethrown exception contains error in error handler"
);