in reply to How do I report an error back to the user of my object?
The above are great solutions, but there is one more.
You may have seen modules that have something like $Foo::errstr or the likes. Setting up something like that isn't too hard:
package Foo::Bar; our $error = ""; sub new { my( $class, @args ) = @_; my $self = bless( \@args, $class ); unless( $self->method_that_might_fail() ) { $Foo::Bar::error = "O noes"; return undef; } return $self; }
Of course, you will have to change that to fit your style, and it is probably a good idea to push the error setting to a separate subroutine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I report an error back to the user of my object?
by polymorpheus (Novice) on Jun 05, 2012 at 13:11 UTC |