Kent Fredric > MooseX-Attribute-ValidateWithException > MooseX::Attribute::ValidateWithException

Download:
MooseX-Attribute-ValidateWithException-0.2.2.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v0.2.2   Source   Latest Release: MooseX-Attribute-ValidateWithException-0.3.1

NAME ^

MooseX::Attribute::ValidateWithException - Cause validation failures to throw exception objects.

VERSION ^

version 0.2.2

SYNOPSIS ^

  {
    package Foo;
    use Moose;
    use MooseX::Attribute::ValidateWithException;

    has foo => (
      isa => 'Str',
      is  => 'rw',
      required => 1,
    );
    __PACKAGE__->meta->make_immutable;
    no Moose;
  }

  use Try::Tiny;

  try {
    Foo->new( foo => { this_is => [qw( not what we were wanting )] } );
  } catch {
    say $_->name if blessed( $_ ) && $_->isa('Thingy');
  };

DESCRIPTION ^

ALPHA QUALITY SOFTWARE.

At present, when an attribute fails validation, Moose internally die()'s with a string. There is also no way to throw an exception object as part of the validation message, ( in order to give more context on the problem ), without also breaking how much of the validation works.

This module is an experiment in providing that feature, which really should be done in Moose itself, and done better, which is why it has been given such an obtuse name.

This module makes no promises of forwards compatibility with a future Moose release, in order to permit Moose to do whatever they want and not worry about "breaking code" that uses this module. ( So that they can easily replace this module in incompatible ways )

If your code breaking is unacceptable, do not use this module.

Use of this module assumes several things.

1. You are o.k. with your code breaking in a future Moose release.
2. You are o.k. with re-writing any and all code that depends on this functionality, if a future Moose release is incompatible with this module.

I'm not saying I won't do my best to provide forwards compatibility, but it is highly unlikely it will be possible, due to differences in package naming which may be essential for handling exceptions.

AUTHOR ^

Kent Fredric <kentnl@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Kent Fredric <kentnl@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: