From: Karen Etheridge Date: Thu, 7 Apr 2011 19:36:28 +0000 (-0700) Subject: use Moose->throw_error rather than confess X-Git-Tag: v0.14~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-StrictConstructor.git;a=commitdiff_plain;h=714128ef886ae4a37d5aefe6910a7581150ec149 use Moose->throw_error rather than confess --- diff --git a/lib/MooseX/StrictConstructor.pm b/lib/MooseX/StrictConstructor.pm index 5721c41..e7cfda2 100644 --- a/lib/MooseX/StrictConstructor.pm +++ b/lib/MooseX/StrictConstructor.pm @@ -56,7 +56,7 @@ __END__ Simply loading this module makes your constructors "strict". If your constructor is called with an attribute init argument that your class -does not declare, then it calls "Carp::confess()". This is a great way +does not declare, then it calls Cthrow_error()>. This is a great way to catch small typos. =head2 Subverting Strictness diff --git a/lib/MooseX/StrictConstructor/Role/Object.pm b/lib/MooseX/StrictConstructor/Role/Object.pm index 4eef0d4..4b5a765 100644 --- a/lib/MooseX/StrictConstructor/Role/Object.pm +++ b/lib/MooseX/StrictConstructor/Role/Object.pm @@ -18,8 +18,8 @@ after 'BUILDALL' => sub { my @bad = sort grep { !$attrs{$_} } keys %{$params}; if (@bad) { - confess - "Found unknown attribute(s) init_arg passed to the constructor: @bad"; + Moose->throw_error( + "Found unknown attribute(s) init_arg passed to the constructor: @bad"); } return; diff --git a/lib/MooseX/StrictConstructor/Trait/Class.pm b/lib/MooseX/StrictConstructor/Trait/Class.pm index 1bfb0f5..0c73318 100644 --- a/lib/MooseX/StrictConstructor/Trait/Class.pm +++ b/lib/MooseX/StrictConstructor/Trait/Class.pm @@ -5,7 +5,6 @@ use Moose::Role; use namespace::autoclean; use B (); -use Carp (); around '_inline_BUILDALL' => sub { my $orig = shift; @@ -25,7 +24,7 @@ around '_inline_BUILDALL' => sub { 'my %attrs = (' . ( join ' ', @attrs ) . ');', 'my @bad = sort grep { !$attrs{$_} } keys %{ $params };', 'if (@bad) {', - 'Carp::confess "Found unknown attribute(s) passed to the constructor: @bad";', + 'Moose->throw_error("Found unknown attribute(s) passed to the constructor: @bad");', '}', ); }; diff --git a/lib/MooseX/StrictConstructor/Trait/Method/Constructor.pm b/lib/MooseX/StrictConstructor/Trait/Method/Constructor.pm index 3c228b0..0ceec12 100644 --- a/lib/MooseX/StrictConstructor/Trait/Method/Constructor.pm +++ b/lib/MooseX/StrictConstructor/Trait/Method/Constructor.pm @@ -5,7 +5,6 @@ use Moose::Role; use namespace::autoclean; use B (); -use Carp (); around '_generate_BUILDALL' => sub { my $orig = shift; @@ -27,7 +26,7 @@ my \%attrs = (@attrs); my \@bad = sort grep { ! \$attrs{\$_} } keys \%{ \$params }; if (\@bad) { - Carp::confess "Found unknown attribute(s) passed to the constructor: \@bad"; + Moose->throw_error("Found unknown attribute(s) passed to the constructor: \@bad"); } EOF