Hello everyone,
I once again have a broad question about implementing a certain capability.
Consider we have the following:
main program -> uses modules A & B
|
|
execute exported sub from A (A uses C & D)
| |
| execute exported sub from C
| |
| execute exported sub from D
|
execute exported sub from B
Both C and D are expected to return a value (an array for say) and then all
of those will be passed to B for some more crunching and the result gets
spit out back to main. I am passing only one structure around per every
execution so I figured objects are out of question. However before I invoke
B I need to make sure that C and D completed without warnings and if they
did have any - change the behavior of B slightly.
What I did originaly was return ([EMAIL PROTECTED], [EMAIL PROTECTED]) from
each C and D,
check if data is present, otherwise die, and then check if warnings is
present and do necessary adjustments.
While this works for the above, it does not scale too well, and when I
started adding E, F, G, H and so on, reaching down more and more levels, it
bacame very error prone. I looked on CPAN for general error reporting
mechanisms but only came up with Carp (which from my understanding is more
of a debugging tool for real warnings and exceptions) and Error (which looks
like an overkill for what I want to have).
I started thinking to implement a simple module (ErrorReport.pm for
instance), have it export methods 'error' and 'warning' which will take a
string and stuff it in the corresponding internal array. Then use this
module in each of my modules which mught want to say something, and then
have another function to retrieve everything we have so far at the point
between A and B (or make the variables global with use vars/our and
access them directly by @ErrorReport:: for that matter). Internally I was
going to use caller() to record the whistleblower alongside its message.
My question is - is this too simple to be true? I suspect this is probably
not thread-safe (not that I know much about threads anyway), but are there
any other obvious shortcommings that I am missing? Maybe there is a well
developed framework to handle problems like mine and I am reinventing the
wheel due to lack of knowingbetterness?
I would appreciate any comments/suggestions/reading references.
Thank You
Peter
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>