in reply to Dancer2 hook

We need a Short, Self-Contained, Correct Example here. What is the code you are using?

I realize you posted this anonymously, so you will need to post the code that is not working in a reply. Maybe someone will be able to help you.

Replies are listed 'Best First'.
Re^2: Dancer2 hook
by Anonymous Monk on Aug 13, 2019 at 00:23 UTC
    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?
      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.