Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 47636
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: perl [...] evancarroll.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: [TEST ATTACHED] Error messages should be consistant if there is no coercion
I would like if the error messages were consistent when I was omitting coercions... The run time setter error is elegant, the instantiation error is crufty.
Subject: moose_coercion_error_messages.t
#!/usr/bin/env perl ## Not sure why these two should return different errors ## Personally, I like "Cannot coerce without a type coercion" better ## Evan Carroll <me@evancarroll.com> ## package Class; use Moose; use Moose::Util::TypeConstraints; subtype 'Type' , as 'Str'; has 'foo' => ( isa => 'Type', is => 'rw' , coerce => 1 ); package main; use Test::More tests => 4; eval { my $o = Class->new->foo( \my $foo ); }; unlike ( $@, qr/Validation failed for 'Type' failed with value/, 'Runtime: No stupid error message' ); like ( $@, qr/Cannot coerce without a type coercion/, 'Runtime: Good error message' ); eval { my $o = Class->new({ foo => \my $foo }); }; unlike ( $@, qr/Validation failed for 'Type' failed with value/, 'Constructor: No stupid error message' ); like ( $@, qr/Cannot coerce without a type coercion/, 'Constructor: Good error message' );
Shorter test attached without the subtype, less complexity
#!/usr/bin/env perl ## Not sure why these two should return different errors ## Personally, I like "Cannot coerce without a type coercion" better ## Evan Carroll <me@evancarroll.com> package Class; use Moose; has 'foo' => ( isa => 'Str', is => 'rw' , coerce => 1 ); package main; use Test::More tests => 4; eval { my $o = Class->new->foo( \my $foo ); }; unlike ( $@, qr/Validation failed for 'Str' failed with value/, 'Runtime: No stupid error message' ); like ( $@, qr/Cannot coerce without a type coercion/, 'Runtime: Good error message' ); eval { my $o = Class->new({ foo => \my $foo }); }; unlike ( $@, qr/Validation failed for 'Str' failed with value/, 'Constructor: No stupid error message' ); like ( $@, qr/Cannot coerce without a type coercion/, 'Constructor: Good error message' );
Subject: Re: [rt.cpan.org #47636] [TEST ATTACHED] Error messages should be consistant if there is no coercion
Date: Tue, 7 Jul 2009 02:41:47 -0500
To: bug-Moose [...] rt.cpan.org
From: Yuval Kogman <nuffin [...] cpan.org>
The error, if any, should be at declaration time. I have no real opinion on this, maybe someone else wants to comment?
I consider this resolved since Moose now warns (and will eventually die in later versions) when you pass "coerce => 1" for a type without a coercion.