Hi all,
I am writing an OO module for my own needs (and as a learning experience as well), and I am trying to gather all the error messages possibly emitted by other modules (DBI, mainly). So far, I have laid down the following course of action:
The private variable is simply called _error, accessed by an error() method that simply returns the string and resets _error to the empty string.
So far, this works fine under the environment I am using (mod_perl), with one little issue: if the constructor method encounters an error and returns undef, I can't use it like this for obvious reason:
my $obj = MyModule->new() or die $obj->error();DBI uses a global variable for a similar purpose I believe, any caveat I should be aware of before trying that myself?
To sum it up, I am looking for advices concerning any better method I couldn't think of to achieve the same thing, whether it is a commonly used and proven solution, or an existing module (I have searched for "error", "wrapper", and many variations thereof but didn't quite find a fitting tool).
Thanks in advance for any advice you will provide.
In reply to Error wrapping in an OO module by Fang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |