Re: When and how to throw exceptions?

2010-04-10 Thread David Nicol
On Fri, Apr 9, 2010 at 1:54 AM, Ovid publiustemp-moduleautho...@yahoo.comwrote: (Javaesque psuedo-code): try { customer.read(); } catch ( Exception::IO::NotFound e ) { ... } catch ( Exception::IO::CantOpen e ) { ... } catch ( Exception::IO::CantRead e ) { ... } catch (

Re: When and how to throw exceptions?

2010-04-09 Thread Aristotle Pagaltzis
* Ovid publiustemp-moduleautho...@yahoo.com [2010-04-09 08:55]: Buut ... that's why you want those exceptions in classes instead of as hash keys. Of course. Just saying that if you *do* consider too many exception classes a problem in need of a solution, then using a field as a message

Re: When and how to throw exceptions?

2010-04-08 Thread Aristotle Pagaltzis
* Ovid publiustemp-moduleautho...@yahoo.com [2010-04-07 09:05]: Presumably the format should try to determine the number of conversions in the format and perhaps the alias could generate a sub with a corresponding prototype like 'sub throw_io_read($$)'. That might give you a touch of

Re: When and how to throw exceptions?

2010-04-08 Thread Lutz Gehlen
Hi Ovid, On Wed, Apr 07, 2010 at 12:04:08AM -0700, Ovid wrote: --- On Wed, 7/4/10, Lutz Gehlen lrg...@gmx.net wrote: What I need a central place for is the definition of the actual error messages. With my module Exception::EasyThrow, I can write at the beginning of my module:

Re: When and how to throw exceptions?

2010-04-08 Thread Aristotle Pagaltzis
* Lutz Gehlen lrg...@gmx.net [2010-04-09 01:55]: I think that an own class for each message might be a bit of an overkill. Why? I guess that could be addressed by allowing a hash of formats and then offering the throwing site to pick one of them by setting a special field. The key here is

Re: When and how to throw exceptions?

2010-04-06 Thread Lutz Gehlen
Hi Aristotle, sorry for the delayed reply, I had some computer problems and then this topic slipped a bit out of my mind. On Friday 12 March 2010 23:33:40 Aristotle Pagaltzis wrote: * Lutz Gehlen lrg...@gmx.net [2010-02-21 01:40]: 1) The first question deals with how to throw exceptions

Re: When and how to throw exceptions?

2010-03-12 Thread Aristotle Pagaltzis
Hi Lutz, * Lutz Gehlen lrg...@gmx.net [2010-02-21 01:40]: 1) The first question deals with how to throw exceptions properly. In projects which ask for a more sophisticated way than just carping or croaking I use Exception::Class. However, in both cases the error message has to be assembled

Re: When and how to throw exceptions?

2010-03-12 Thread Dave Rolsky
On Fri, 12 Mar 2010, Aristotle Pagaltzis wrote: I’m sure you can already imagine where this is going: basically, you should check your own intermediate computed values, to ensure you don’t propagate error conditions sideways between parts of your own code. But if you operate on user input

Re: When and how to throw exceptions?

2010-02-21 Thread Daniel Staal
--As of February 21, 2010 1:43:58 PM +1300, Lutz Gehlen is alleged to have said: Therefore I would like to define my error messages in some sprintf format way at a central place and use these templates when the time has come. I have written a module Exception::Class::EasyThrow that does this.

When and how to throw exceptions?

2010-02-20 Thread Lutz Gehlen
Hello everybody, I am writing this email to ask two general questions about throwing exceptions. Parts of them are not restricted to Perl and just reflect my general lack of knowledge about how to deal with exceptions in a professional way. So if you think RTFM when you read on, I am happy to