Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give good error location in error message from Moo isa validation #35

Merged
merged 4 commits into from
Feb 8, 2017

Commits on Apr 30, 2015

  1. Configuration menu
    Copy the full SHA
    249efe3 View commit details
    Browse the repository at this point in the history

Commits on May 7, 2015

  1. Merge pull request tobyink#25 from haarg/dict-tuple-warn

    avoid warnings in Dict and Tuple types
    tobyink committed May 7, 2015
    Configuration menu
    Copy the full SHA
    7a4c5f6 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2016

  1. Give good error location in error message from Moo isa validation

    This script in ./tinyMooErrorDemo.pl:
    
        #!/usr/bin/perl -w
        use strict;
    
        {
            package Foo;
            use Moo;
            use Types::Standard qw(Bool);
            has foo => ( is => 'ro', isa => Bool );
        }
    
        Foo->new(foo=>sub {});
    
    Gave this output:
    
        Reference sub { "DUMMY" } did not pass type constraint "Bool" (in $args->{"foo"}) at (eval 62) line 59
            Reference sub { "DUMMY" } did not pass type constraint "Bool" (in $args->{"foo"})
            "Bool" is defined as: (Type::Tiny::XS::Bool($_))
    
    With this commit, it now gives this output:
    
        Reference sub { "DUMMY" } did not pass type constraint "Bool" (in $args->{"foo"}) at ./tinyMooErrorDemo.pl line 11
            Reference sub { "DUMMY" } did not pass type constraint "Bool" (in $args->{"foo"})
            "Bool" is defined as: (Type::Tiny::XS::Bool($_))
    
    Which makes more sense to the caller
    pmorch committed Nov 24, 2016
    Configuration menu
    Copy the full SHA
    e423d71 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2016

  1. Error location detection with Moo needed changing

    Newer versions of Moo (see below) put the contructor into the
    appropriate package, and don't leave it as part of
    "Method::Generate::Constructor", so testing for that package no longer
    works.
    
    Instead test for package /^\(eval \d+\)$/ and (eval) as the sub, and
    if so, $level++.
    
    The change in Moo that broke the previous fix was:
    
        commit 84b6760de8224ee3a020207e08c22810530e417e
        Author: Graham Knop <haarg@haarg.org>
        Date:   Thu Apr 14 16:50:30 2016 -0400
    
            fix croak location for inlined BUILDARGS
    
    included in versions 2.002 or newer.
    pmorch committed Nov 29, 2016
    Configuration menu
    Copy the full SHA
    0122bc9 View commit details
    Browse the repository at this point in the history