Catalyst-ActionRole-DetachOnDie
view release on metacpan or search on metacpan
10111213141516171819202122232425262728is( get(
'/success'
),
'base, success'
,
'Successful chain works'
);
is( get(
'/fail'
),
'base'
,
'Die in base correctly stops chain'
);
is( get(
'/middle_fail'
),
'base'
,
'Die in middle of chain works'
);
is( get(
'/base/success'
),
'base_base, success'
,
'Base Successful chain works'
);
is( get(
'/base/fail'
),
'base_base'
,
'Base Die in base correctly stops chain'
);
is( get(
'/base/middle_fail'
),
'base_base'
,
'Base Die in middle of chain works'
);
is( get(
'/fail_ctx_error'
),
'1, base'
,
'ctx error preserved when die in Chain worked.'
);
my
$res
= request(
'/base/explicit_detach/endpoint'
);
is(
$res
->content,
'base_base, explicit_detach'
,
'explicit detach does not trigger error catching'
);
is(
$res
->header(
'X-DetachOnDie-Caught'
), 0,
'exception not caught by action role'
);
my
$res
= request(
'/pitch_go'
);
is(
$res
->content,
'base, pitched, caught'
,
'Using ->go works'
);
is(
$res
->header(
'X-DetachOnDie-Caught'
), 0,
'... and rethrows the exception untouched'
);
done_testing();
t/lib/Foo/Controller/Root.pm view on Meta::CPAN
7677787980818283848586878889909192939495969798
push
@{
$c
->stash->{body}},
'middle_fail_2'
;
}
sub
explicit_detach : Chained(
'base_base'
) PathPart(
'explicit_detach'
) CaptureArgs(0) ActionClass(
'DetachOnDie'
) {
my
(
$self
,
$c
) =
@_
;
push
@{
$c
->stash->{body}},
'explicit_detach'
;
$c
->res->redirect(
'/success'
);
$c
->detach;
}
sub
explicit_detach_endpoint : Chained(
'explicit_detach'
) PathPart(
'endpoint'
) Args(0) {
my
(
$self
,
$c
) =
@_
;
push
@{
$c
->stash->{body}},
'endpoint'
;
return
;
}
sub
pitch_go : Chained(
'base'
) Args(0) ActionClass(
'DetachOnDie'
) {
my
(
$self
,
$c
) =
@_
;
push
@{
$c
->stash->{body}},
'pitched'
;
$c
->go(
'/catch_go'
);
}
sub
catch_go : Action {
( run in 0.265 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )