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
In reply to Re: How do I report an error back to the user of my object?
by NetWallah
in thread How do I report an error back to the user of my object?
by SomeNetworkGuy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |