Useful bugs for Moose and MooseX :: Declare

The moose is very cute, but sometimes simple typos can cause exciting hair exciting long stacks, from my point of view, zero useful content.

So, are there any tools to interpret this explosion into something useful?

In particular, for classes using simple Moose, Moose + MooseX :: Method :: Signatures and MooseX :: Declare.

Tools should be helpful in developing to catch these typos or typing problems that make things just not work.

===========================

The following sentence below, I use this not quite modular module, but it slightly reduces my headaches, more ideas are welcome:

package MooseX::QuietCarping; # Not actually a Moose thing, but helpful for Moose. # calm Moose-internal stacktraces down a little use Carp; my %retain = (); sub import { my $class = shift; $retain{$_}++ for @_; } CHECK { for (sort keys %INC) { s{\.pm$}{}; s{[/\\]}{::}g; # CROSS PLATFORM MY ARSE next if $retain{$_}; $Carp::Internal{$_}++ if /^(?:Class::MOP|Moose|MooseX)\b/ } %retain = (); # don't need this no more } 1; 
+8
perl moose
source share
3 answers

One way I experimented a while ago is to put Moose related classes in a %Carp::Internal hash, something like this:

 $Carp::Internal{$_}++ for qw{ Class::MOP Class::MOP::Attribute Class::MOP::Class ... }; 

Such classes will be skipped in the stack trace, which will make it more compact and emphasize your own code.

You can find them by passing the %INC variable:

 package Dummy; use Moose; use MooseX::Declare; # use ....; for (sort keys %INC) { s{\.pm$}{}; s{/}{::}g; print "$_\n" if /^(Class::MOP|Moose|MooseX)\b/; } 
+4
source share

It seems to me that I watched the PerlMonks post from stvn a week or two ago, saying that they are working on improving Moose error messages. I do not think there is anything for cleaning at present, though.

+2
source share

Method::Signatures::Modifiers is a package that hopes to fix some MooseX::Method::Signatures problems. Just use overload it.

 use MooseX::Declare; use Method::Signatures::Modifiers; class Foo { method bar (Int $thing) { # this method is declared with Method::Signatures instead of MooseX::Method::Signatures } } 
+2
source share

All Articles