X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FUtil.pm;h=393bccf9940732a68df841d3c9234356f263be2b;hb=dcce2592fe68fba003835495db169f6f9ee2646a;hp=076ca34e85fda07e175387fdd36644b8f2f4492c;hpb=a672bf8660ab37aa9afdea5133975b7d050639ae;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 076ca34..393bccf 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -38,13 +38,13 @@ BEGIN{ not_supported - does meta dump + does meta throw_error dump )], groups => { default => [], # export no functions by default # The ':meta' group is 'use metaclass' for Mouse - meta => [qw(does meta dump)], + meta => [qw(does meta dump throw_error)], }, ); @@ -67,7 +67,7 @@ BEGIN{ Mouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta'); return 1; } || 0; - #warn $@ if $@; + warn $@ if $@ && $ENV{MOUSE_XS}; } if(!$xs){ @@ -337,6 +337,22 @@ sub meta :method{ return Mouse::Meta::Class->initialize(ref($_[0]) || $_[0]); } +# general throw_error() method +# $o->throw_error($msg, depth => $leve, longmess => $croak_or_confess) +sub throw_error :method { + my($self, $message, %args) = @_; + + local $Carp::CarpLevel = $Carp::CarpLevel + 1 + ($args{depth} || 0); + local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though + + if(exists $args{longmess} && !$args{longmess}) { + Carp::croak($message); + } + else{ + Carp::confess($message); + } +} + # general dump() method sub dump :method { my($self, $maxdepth) = @_; @@ -346,6 +362,7 @@ sub dump :method { $dd->Maxdepth(defined($maxdepth) ? $maxdepth : 3); $dd->Indent(1); $dd->Sortkeys(1); + $dd->Quotekeys(0); return $dd->Dump(); } @@ -395,7 +412,7 @@ The same as C. =head2 Class::MOP functions -The followign functions are not exportable. +The following functions are not exportable. =head3 C<< Mouse::Util::is_class_loaded($classname) -> Bool >>