Subject: | Error handling is broken |
Date: | Thu, 14 May 2020 09:28:30 -0600 |
To: | bug-Mojolicious-Plugin-PlackMiddleware [...] rt.cpan.org |
From: | "Larry Leszczynski" <larryl [...] emailplus.org> |
Using Mojolicious::Plugin::PlackMiddleware version 0.36
This code at line 225 in the Mojolicious::Plugin::PlackMiddleware::_EH package mishandles its arguments (the shifts don't happen in the order the code expects):
sub print {
shift->handler->(shift);
}
It should be something like:
sub print {
my ($self, $error) = @_;
$self->handler->($error);
}
The bug can be reproduced like so:
$ perl -Ilib -MMojolicious::Plugin::PlackMiddleware -E '
package Foo;
our @ISA = qw(Mojolicious::Plugin::PlackMiddleware::_EH);
package main;
my $a = Foo->new(handler => sub { print @_ });
$a->print("THIS");'
Can't locate object method "handler" via package "THIS" (perhaps you forgot to load "THIS"?)