Would http://search.cpan.org/~mstrout/Moo-0.009008/lib/Moo.pm work for you? It does a little bit of what Moose does. Part of what is missing is that there isn't a big complex type system. isa is verified with code refs, and you can have custom coderefs. Thus if you gave it coderefs that provide warnings but don't stop you from progressing, then you'd get the effect you're after. Besides, it is even smaller and faster than Mouse. Which, considering the company's preference for Mouse over Moose, might be liked by some of your co-workers. On Fri, Jun 10, 2011 at 3:06 AM, Ovid <publiustemp-catalyst@yahoo.com> wrote: > When I declare a parameter as follows: > > > has 'some_val' => ( > is => 'rw', > isa => 'Int', > ); > > Later if I do $object->some_value("foobar"), it blows up with a stack trace because of the type constraint violation. > > Without using signal handlers, is there some way I can convert that exception into a warning except when something like $ENV{HARNESS_ACTIVE} is true? Preferably on a per-attribute basis? > > Backstory for those who care: we're actually using Mouse instead of Moose and the company may decide to eliminate Mouse. Currently the odds of upgrading to Moose are roughly zero (not my decision), so if there's a solution using Moose but it does not work with Mouse, we may just have Mouse eliminated entirely and not get Moose, either (long story). > > So if we have a hotel whose "short description" is missing or longer than 200 characters, we can live with that, but we can't live with an invalid price. We're happy to clean up bad information but we don't want type constraints to throw out *everything* just because someone goofed (often an external data source we have little control over). Part of the reason management is very unhappy with our use of Mouse is because of these type constraints causing application failure we've never had in the past. We much prefer to bend rather than break. > > Cheers, > Ovid > > -- > Live and work overseas - http://overseas-exile.blogspot.com/ > Buy the book - http://www.oreilly.com/catalog/perlhks/ > Tech blog - http://blogs.perl.org/users/ovid/ > Twitter - http://twitter.com/OvidPerl/Thread Previous | Thread Next