I am looking for recommendations for a better name for an exception handling module I wrote about a month ago.
The current name Exception::Lite reflects its original motivation, but not its purpose at all. Even though it is still light weight (really! it doesn't take much to create all the features I list below), it has a lot of features that aren't at all advertised by its name.
I developed the module because the existing OOP-ish exception handling modules on CPAN were heavy on things I didn't really need (syntactic sugar, per-property accessor methods) and didn't have the features I really, really did need to construct messages and debug code efficiently. The closest I came was Exception::Base which is about the only module on CPAN that captures the thread id, but it doesn't provide the property/message integration or debugging information that I crave. Features like:
Closely integrated messages and exceptions properties. I wanted to be able to assign values to properties and have the message autogenerated based on those property values. The code for it is really quite simple, but for some reason, none of the modules consider this terribly important. Not only does this save time and typing, it also makes it much easier to retrofit the code with localized messages: just stick the property values into a new language specific format string.
The thread id at the time the message is generated.
Chained exceptions. Sometimes what a low level module considers important about an exception is not what a higher level module considers important. When that happens I want to create a new exception with a more relevant error message that "remembers" the exception that inspired it so if need be, I could see the entire history from origin to destination.
The ability to see propagation history (where an exception is rethrown) and not just the chain of calls that were made to get to the original place the exception was generated.
A stack trace that tells me what subroutine the problematic code of line is located in rather than what subroutine was called on the problematic line. If I'm scanning a chain of calls, I want to see the context where the problem occured not just a pinhole view of the actual line where the problem occured.
A stack trace that won't lie to me about the parameters that are being passed to subroutines. I know it is impossible to recreate the actual values in the parameter list because the parameter list for any sub is just @_ and that can be modified when a programmer uses shift to process command line arguments. The most the DB module can give me is the way @_ looked at the time the next frame in the stack was set up. Still most stack traces are formatted as if they are showing the actual parameters passed to the sub rather than what was left of them by the time the next stack frame was set up.
If the programmer used my ($arg1, $arg2,...) = @_ and never used shift or anything else that modifies @_ it will just happen to be the values passed to that subroutine. But often subroutine arguments are processed with shift and by the time the next subroutine is called, @_ is stuffed with a bunch of leading undef's. It no longer looks like it did when the sub was originally called. Why not just tell me it is the value of @_ at the time the next frame was created so I don't think I passed a heap of undef's to my subroutine? Better yet, provide me some sort of visual hint that those undefs might be bogus so I don't have to do that extra thinking step each time I see them. I want to focus on the code, not on remembering the quirks of Perl stack tracing.
An uncluttered stack trace where I can easily control the amount of detail and won't have error messages truncated (a problem with Carp::croak). Sometimes being able to see what subroutine was calling what other subroutine will tell me everything I need to locate the bug. I don't always want to see chained exceptions, the propagation sequence or even what's left of @_ at the time the next frame in the stack was generated. In fact, that is true most of the time. All I need is a simple list of what called what on which line of which file.
Can shed its OOPishness and still be useful when someone tries to handle it and doesn't know or care what sort of exception it is. I want it to be used as a string in string context. I want it to be well behaved in equalities and compare reference addresses. It needs to be thrown and rethrown using normal Perl symantics, e.g. die $myerr to throw and die without parameters to rethrow.
On my less important but still nice list:
OK. I'm done. It isn't much really? Is it?
Fortunately not. The actual exception classes are between 30 and 45 LOC even with all the property/message integration. The code to set up and control the stack trace, chained exceptions, and propagation history amount to another 150 lines. Perl has some marvelously efficient tools for exception handling in its core. They just need to be assembled. caller, DB::args, sprintf, overload and PROPAGATE are my friends.
Being light weight is an advantage, but not its real value, at least not to me. Thus I consider the current name not very useful, especially if I ever get the courage to submit it to CPAN. (The long term responsibility of maintainership worries me which is why I haven't released any modules to date.)
Some of the names I've considered:
As you can see I am naming impaired and would welcome help from my fellow monks. And if someone helps me come up with a decent name and if someone other than I thinks that these features would be helpful, I'll consider biting the bullet of long term responsibility (any thoughts on that issue would be welcome as well, by the way), and post this module to CPAN.
Update: added code, pod excerpts, and test suite in reply Re^2: RFC: A better name for an exception handling module? as per TGI's request.
In reply to RFC: A better name for an exception handling module? by ELISHEVA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |