Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

$obj->mo->super() breaks inside a Try::Tiny block #201

Open
nilsonsfj opened this Issue · 3 comments

3 participants

@nilsonsfj

Well, there's not much to say here besides what's in the subject.

The error message I get is: "Can't locate object method "ANON" via package "My::Package" which seems to indicate that when walking up the call stack, it's getting fooled by something injected by Try::Tiny.

Running Perl 5.10.1, on Windows (Strawberry).

Sample (mostly real) code:

method process_message ($data) {
    try {
        given ( $data->{type} ) {
            when ("connect") {
                # ...
            }
            when ("connect_ok") {
                # ...
            }
            default {
                $self->mo->super( $data );
            }
        };
    }
    catch {
        say "$self - Process Message Error: $_ [closing]";
        $self->close_connection;
    };
}

Is this even fixable?

@exodist
@nilsonsfj

Well, maybe I wasn't clear, but the exception is thrown at the $self->mo->super( $data ) line.

If I don't use the "super" method (i.e. call the superclass method explicitly) it works. If I remove the try/catch blocks it also works.

So the problem is an interaction between Try::Tiny and perl5i. Also I guess GitHub mangled the original error message, turning the placeholder ANON into bold text.

Can't locate object method "__ANON__" via package "My::Package" at My/Package.pm line 62

Where line 62 is the line of the "super" call.

@schwern
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.