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/

Reply via email to