develooper Front page | perl.moose | Postings from June 2011

Re: Moose Type Constraints violations to warnings?

Thread Previous
From:
Ovid
Date:
June 10, 2011 03:11
Subject:
Re: Moose Type Constraints violations to warnings?
Message ID:
978854.55134.qm@web65715.mail.ac4.yahoo.com
>________________________________
>From: Ovid <publiustemp-catalyst@yahoo.com>
>To: Moose <moose@perl.org>
>Sent: Friday, 10 June 2011, 12:06
>Subject: Moose Type Constraints violations to warnings?
>
>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?

Naturally, despite searching beforehand, I found the answer ("no, you can't do that") immediately after I sent this:

    http://search.cpan.org/dist/Moose/lib/Moose/Manual/FAQ.pod#Can_I_turn_off_type_constraint_checking?

    Can I turn off type constraint checking?
    Not yet. This option may come in a future release.

Hopefully this email might at least spur discussion.

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About