CPAN::Forum
Object-InsideOut - Re: :Init attribute and OIO::Args exception
| Posted on Tue Jan 9 17:45:30 2007 by jdhedden in response to 3996 (See the whole thread of 3) |
| Re: :Init attribute and OIO::Args exception |
|
You must have some other issue. The following:
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
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__);
}
}
}
package main;
MAIN:
{
my $obj = Class_Object2->new();
}
exit(0);
# EOF
Produces:
OIO::Args error: Missing mandatory arg
Usage: Must specify at least one of 'attribute1' and 'attribute2'
Package: main
File: oio.pl
Line: 38
Trace begun at oio.pl line 38
The OIO::Args error is throw via line 1512 in the 'new' subroutine, not inside '_args'. Exactly what error message are you getting?
|
| Direct Responses: 4000 | Write a response |
(2)
]