develooper Front page | perl.module-authors | Postings from June 2008

Name space: throwing exceptions easily

Thread Next
From:
Lutz Gehlen
Date:
June 28, 2008 04:53
Subject:
Name space: throwing exceptions easily
Message ID:
200806281351.57391.lrg_ml@gmx.net
Hello everybody,
I am developing a module to make throwing Exception::Class objects 
easier. The goal is to make the code to throw an exception shorter 
and to make it possible to keep all error messages at some central 
place.

The module works quite similarly to Class::Accessor and provides a 
function mk_exception_functions that puts the required functions 
into a given namespace. For example you can define an exception 
like
__PACKAGE__->mk_exception_functions
    (messages => {foo => 'Error foo occurred.'},
    exception_class => 'Exception::Class::Mine');

and later just call
foo() if($foo);
instead of
Exception::Class::Mine->throw(message => 'Error foo occurred.')
    if($foo);

Currently the module uses the package Exception::Class::EasyThrow 
but I don't know if this is really a good name. It is a bit vague 
and rather refers to the intended use of the module instead of what 
it does.

I would be happy about other suggestions.

Thanks a lot,
Lutz

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About