in reply to Re: Dancer2 hook
in thread Dancer2 hook

Thanks for the reply. The hook works fine. But it's the implementation that I am having trouble with. By implementation, I mean, putting the hook in a module that I can then use when I want the hook to be applied to errors.

So the code part is real simple:

hook after_error => sub { my $response = shift; };
The problem is that this code is not catching errors from the application that uses the module. Get it?

Replies are listed 'Best First'.
Re^3: Dancer2 hook
by Anonymous Monk on Aug 13, 2019 at 00:42 UTC
    That is not demonstrative self contained code
      Correct. Here you go:
      package Dancer2::Plugin::TestHook use Dancer2; use Dancer2::Core::Error; hook after_error => sub { my $content = shift; $content->{content} .= "hello world"; } 1;
      This hook works fine, but it doesn't get called when I use the module (Dancer::Plugin::TestHook) somewhere else. That's the problem.

        Still incomplete.

        Where is the app that triggers an error?