X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod.pm;h=a9fd8bb7a419c5173375e6b06fe97c9f8af052d8;hb=d344c3feeb1c99183a249e26ddfb0e790101f7b2;hp=bd97cd15d7d2ac943d7f7438e00ca49430428faf;hpb=ecb59493ea0e2ccb95c40bd2131f3492362cd48b;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method.pm b/lib/Moose/Meta/Method.pm index bd97cd1..a9fd8bb 100644 --- a/lib/Moose/Meta/Method.pm +++ b/lib/Moose/Meta/Method.pm @@ -3,10 +3,32 @@ package Moose::Meta::Method; use strict; use warnings; -our $VERSION = '0.01'; +our $VERSION = '0.68'; +$VERSION = eval $VERSION; +our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method'; +sub _error_thrower { + my $self = shift; + ( ref $self && $self->associated_metaclass ) || "Moose::Meta::Class"; +} + +sub throw_error { + my $self = shift; + my $inv = $self->_error_thrower; + unshift @_, "message" if @_ % 2 == 1; + unshift @_, method => $self if ref $self; + unshift @_, $inv; + my $handler = $inv->can("throw_error"); + goto $handler; # to avoid incrementing depth by 1 +} + +sub _inline_throw_error { + my ( $self, $msg, $args ) = @_; + "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard +} + 1; __END__ @@ -23,6 +45,16 @@ For now, this is nothing but a subclass of Class::MOP::Method, but with the expanding role of the method sub-protocol, it might be more useful later on. +=head1 METHODS + +=over 4 + +=item throw_error $msg, %args + +=item _inline_throw_error $msg_expr, $args_expr + +=back + =head1 BUGS All complex software has bugs lurking in it, and this module is no @@ -33,15 +65,13 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE -Yuval Kogman Enothingmuch@woobling.comE - =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut