The last commit didn't correctly catch 1 v.s. 1.5, use Perl's fmod function to check...
[gitmo/Mouse.git] / xs-src / MouseAttribute.xs
index f8012da..617a99a 100644 (file)
@@ -280,10 +280,7 @@ CODE:
 
     /* taken from Class::MOP::Attribute::new */
 
-    if(!SvOK(name)){
-        mouse_throw_error(klass, NULL,
-            "You must provide a name for the attribute");
-    }
+    must_defined(name, "an attribute name");
 
     svp = hv_fetchs(args, "init_arg", FALSE);
     if(!svp){
@@ -297,7 +294,7 @@ CODE:
     svp = hv_fetchs(args, "builder", FALSE);
     if(svp){
         if(!SvOK(*svp)){
-            mouse_throw_error(klass, NULL,
+            mouse_throw_error(klass, *svp,
                 "builder must be a defined scalar value which is a method name");
         }
         can_be_required = TRUE;
@@ -305,7 +302,7 @@ CODE:
     }
     else if((svp = hv_fetchs(args, "default", FALSE))){
         if(SvROK(*svp) && SvTYPE(SvRV(*svp)) != SVt_PVCV) {
-            mouse_throw_error(klass, NULL,
+            mouse_throw_error(klass, *svp,
                "References are not allowed as default values, you must "
                 "wrap the default of '%"SVf"' in a CODE reference "
                 "(ex: sub { [] } and not [])", name);