goto \&confess
}
+sub throw_exception {
+ shift;
+
+ my %args;
+ if (@_ == 1) {
+ $args{message} = shift;
+ }
+ else {
+ %args = @_;
+ }
+
+ my $roles = delete($args{roles});
+
+ my $metaclass = Moose::Meta::Class->create_anon_class(
+ superclasses => ['Throwable::Error'],
+ ($roles ? (roles => $roles) : ()),
+ );
+
+ $metaclass->name->throw(\%args);
+}
+
sub extends {
my $meta = shift;
- Moose->throw_error("Must derive at least one class") unless @_;
+ Moose->throw_exception("Must derive at least one class") unless @_;
# this checks the metaclass to make sure
# it is correct, sometimes it can get out
To learn more about extending Moose, we recommend checking out the
"Extending" recipes in the L<Moose::Cookbook>, starting with
-L<Moose::Cookbook::Extending::Recipe1>, which provides an overview of
+L<Moose::Cookbook::Extending::ExtensionOverview>, which provides an overview of
all the different ways you might extend Moose. L<Moose::Exporter> and
L<Moose::Util::MetaRole> are the modules which provide the majority of the
extension functionality, so reading their documentation should also be helpful.