MooseX::Constructor::AllErrors::Error::Misc - represents a miscellaneous error
version 0.025
This class represents an error occurring at construction time that cannot be classified as one of the other error types. The error message is an arbitrary string, which describes the nature of the error.
Its creation is a little different than the other error types - it must be explicitly created by the generating class, usually in either BUILDARGS or BUILD:
BUILDARGS
BUILD
sub BUILD { my ($self, $args) = @_; my @errors; # either name *or* id is required push @errors, MooseX::Constructor::AllErrors::Error::Misc->new( message => 'Either \'name\' or \'id\' must be provided', ) if not defined $args->{name} and not defined $args->{id}; ...; if (@errors) { my $error = MooseX::Constructor::AllErrors::Error::Constructor->new( caller => [ caller( Class::MOP::class_of($self)->is_immutable ? 2 : 4) ], ); $error->add_error($_) foreach @errors; die $error; } }
This code is a little long and unwieldy; it is likely that a shortcut will soon be added; it has been suggested that support for a VALIDATE sub be added, which is automatically called at construction time before BUILD, to perform validations with no side effect. Stay tuned to upcoming releases!
Returns a human-readable error message for this error.
Moose
Hans Dieter Pearcey <hdp@cpan.org>
This software is copyright (c) 2009 by Hans Dieter Pearcey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::Constructor::AllErrors, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Constructor::AllErrors
CPAN shell
perl -MCPAN -e shell install MooseX::Constructor::AllErrors
For more information on module installation, please visit the detailed CPAN module installation guide.