Catalyst-ActionRole-DetachOnDie

 view release on metacpan or  search on metacpan

t/basic.t  view on Meta::CPAN

is( 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

    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 {

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.084 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )