Hello Eric, On Sun, Jun 29, 2008, Eric Wilhelm wrote: > # from Lutz Gehlen > # on Saturday 28 June 2008 04:51: > >__PACKAGE__->mk_exception_functions > > (messages => {foo => 'Error foo occurred.'}, > > exception_class => 'Exception::Class::Mine'); > > > >and later just call > >foo() if($foo); > > This requires you to inherit from the exception class, but it > installs functions instead of methods?
In fact, it does not inherit from Exception::Class. Exception::Class is not a classical class itself after all but offers via its import function to define subclasses of Exception::Class::Base. My module installs functions because I see an exception as something that belongs to a package. However, I already thought about also offering an mk_exception_methods function for people who prefer to throw an exception with a method call. > If the only call needed is mk_exception_functions(), that could > just be import(). Well, the reason against that is the mk_exception_methods function I just mentionend. But I had not thought of using import, it's a nice idea. Thanks for your feedback, Lutz