I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-01-09 15:27:07-08 by gaetan
:Init attribute and OIO::Args exception
Hello all and happy new year !
In one of my previous mail I sent, I sent the following question:
An object has 2 attributes, each one having a type. Only one of these attributes is mandatory for the object. How can I express it with your module?
Jerry, your response was:
"The easiest way is to use an :Init subroutine:
package Class_Object2; { use Object::InsideOut; my @attribute1 :Field :Arg('name' => 'attribute1') :Type(ClassName1); my @attribute2 :Field :Arg('name' => 'attribute2') :Type(ClassName2); sub init :Init { my ($self, $args) = @_; # Must have at least one of these if (! defined($attribute1[$$self]) && ! defined($attribute2[$$self])) { OIO::Args->die( 'error' => 'Missing mandatory arg', 'Usage' => q/Must specify at least one of 'attribute1' and 'attribute2'/, 'ignore_package' => __PACKAGE__); } } }

But if I create a object Class_Object2 with no parameter, OIO::Code exception is raised instead of OIO::Args (OIO::Args exception is not rethrown in subroutine _args from InsideOut.pm)
Is it possible to retrieve the OIO::Args exception !
Thanks
Direct Responses: 3999 | Write a response