So I've been diving into Moose and I've learned a few things. One thing is that it brings some rigor to the code that I definitely like. Another thing is that debugging ranges from mildly annoying to torturously painful. I'm coming up with an error like below (added whitespace for an attempt at readability):


MooseX::Types::TypeDecorator->new was called with args (MooseX::Types::TypeDecorator,Program::Types::Pattern)
MooseX::Types::TypeDecorator->new was called with args (Program::Types::Pattern,name,pattern1,mask_data,,tags,HASH(0x1fb9eb8))

Argument cannot be 'name' at /nfs/pdx/disks/nehalem.pde.077/tmp/MooseX/Types/TypeDecorator.pm line 89

MooseX::Types::TypeDecorator::new('MooseX::Types::TypeDecorator=HASH(0x1fbe568)', 'name', 'pattern1', 'mask_data', '', 'tags', 'HASH(0x1fb9eb8)') called at /nfs/pdx/disks/nehalem.pde.077/projects/lib/Program-Plist-Pl/lib/Program/Plist/Pl.pm line 52

Program::Plist::Pl::_create_pattern_obj('Program::Plist::Pl=HASH(0x1f682d0)', 'pattern1', undef, undef) called at /nfs/pdx/disks/nehalem.pde.077/projects/lib/Program-Plist-Pl/lib/Program/Plist/Pl.pm line 74

Program::Plist::Pl::BUILD('Program::Plist::Pl=HASH(0x1f682d0)', 'HASH(0x1fbb328)') called at generated method (unknown origin) line 101

Program::Plist::Pl::new('Program::Plist::Pl', 'name', 'test_plist', 'parents', 'HASH(0x1fc8918)', 'external_pl_code', 'CODE(0x7bd990)', 'fh', 'GLOB(0x63d220)', ...) called at Program-Plist-Pl.t line 23


The first two lines are my own debug output placed into a local copy of MooseX::Types::TypeDecorator.pm. The remainder is the result of the error.

While I'd certainly be interested in what is causing this error (I've probably wasted a day looking over code), I'm more interested in how to debug MooseX in general.

Looking at the callstack above, I see the call from Program::Plist::Pl::_create_pattern_obj (which looks good from the arguments standpoint) and then suddenly an error from MooseX::Types::TypeDecorator->new. The first two lines show the problem. TypeDecorator->new seems to expect two arguments: A self reference like any oo call, and what appears to be a MooseX type object as the first argument. However, the failing ->new call seems to show there is no TypeDecorator self reference, and the arguments from the Program::Plist::Pl::_create_pattern_obj call seem to have been pushed to the argument list. Just in case it helps, the _create_pattern_obj call is a wrapper that slightly modifies the arguments and passes them to Program::Plist::Pl->new to get a Pl object. I've verified the underlying new call works fine with the same arguments it's receiving here when it's outside of this code.

First, I'd obviously like to know what's happening above. I didn't post code because there's too much, so I understand if there's not enough to go on here. More importantly, how does one debug into the above type of issue, or Moose in general? I'm typically a primitive instrumentation type of debugger, but the above problem is stemming from code that both may not even exist to instrument (created by Moose based on my class) and is not showing up in the call stack. Where was TypeDecorator->new called from? I'm betting Carp is cleaning out the rest of the stack...any way to keep it?

Thanks for the help guys :) As always it's extremely appreciated. Maybe some day I'll get good enough to start returning some favors :)


In reply to Moose again...Debugging? by tj_thompson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.