From: gfx Date: Mon, 6 Sep 2010 04:20:46 +0000 (+0900) Subject: Resolve RT#61076 (improve error messages) X-Git-Tag: 0.65~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b6f6f7b2fcaeacaecaf85662e7a1ff2c87b087e2;p=gitmo%2FMouse.git Resolve RT#61076 (improve error messages) --- diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index f786e09..97de717 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -150,9 +150,18 @@ sub _create_type{ if($TYPE{$name}){ my $that = $TYPE{$name}->{package_defined_in} || __PACKAGE__; - ($this eq $that) or Carp::croak( - "The type constraint '$name' has already been created in $that and cannot be created again in $this" - ); + if($this ne $that) { + my $note = ''; + if($that eq __PACKAGE__) { + $note = sprintf " ('%s' is %s type constraint)", + $name, + scalar(grep { $name eq $_ } list_all_builtin_type_constraints()) + ? 'a builtin' + : 'an implicitly created'; + } + Carp::croak("The type constraint '$name' has already been created in $that" + . " and cannot be created again in $this" . $note); + } } } else{