in reply to How do I report an error back to the user of my object?
It should default to the empty string.
Update: On second thoughts, it should also be available as a CLASS method - perhaps setup a private Class variable (our $ERRORSTR), that can be accessed via $ClassName::ERRORSTR
This would be necessary/useful in the event that the "new" method failed to instantiate an object.
I could see coding a method like this:
Update> Add "ref" to sub errorstr, based on tobylink and polymorpheus's comments below.our $ERRORSTR=""; sub new{ ... on failure, $ERRORSTR="*KAPUT*: Monkeywrench in our NEW method"; } sub OtherMethod{ .. on error, $self->{ERRORSTR}="*KAPUT* I really hate that parameter + you tried to pass to me"; return -1; } sub errorstr{ # Both class, and Instance Method my ($self)=@_; ref $self or return $ERRORSTR; # Class call return defined ($self->{ERRORSTR}) ? $self->{ERRORSTR} : $ERRORSTR; }
I hope life isn't a big joke, because I don't get it.
-SNL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I report an error back to the user of my object?
by tobyink (Canon) on Jun 05, 2012 at 06:21 UTC | |
|
Re^2: How do I report an error back to the user of my object?
by polymorpheus (Novice) on Jun 05, 2012 at 13:15 UTC | |
by NetWallah (Canon) on Jun 05, 2012 at 13:47 UTC |