From: Jesse Luehrs <doy@tozt.net>
Date: Mon, 2 May 2011 21:12:33 +0000 (-0500)
Subject: better argument checking for ->new
X-Git-Tag: 0.30~2
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=774f4f10836a4e4fa82468d11d0e59730c431399;p=gitmo%2FPackage-Stash.git

better argument checking for ->new
---

diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm
index 9004c5d..fdb8da9 100644
--- a/lib/Package/Stash/PP.pm
+++ b/lib/Package/Stash/PP.pm
@@ -26,6 +26,17 @@ This is a backend for L<Package::Stash> implemented in pure perl, for those with
 sub new {
     my $class = shift;
     my ($package) = @_;
+
+    if (!defined($package) || (ref($package) && ref($package) ne 'HASH')) {
+        confess "Package::Stash->new must be passed the name of the "
+              . "package to access";
+    }
+    elsif (ref($package) eq 'HASH') {
+        confess "The pure perl implementation of Package::Stash doesn't "
+              . "currently support anonymous stashes. You should install "
+              . "Package::Stash::XS";
+    }
+
     return bless {
         'package' => $package,
     }, $class;