Re: MySQL class. Thoughts?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay Moore schreef:
> 
>> I know it's very OO-y to use exceptions, but I hate them. They're like
>> setjmp/longjmp calls in C, and they're a really headache to deal with.
>> If you don't use default or predone handlers, you have to put all kinds
>> of try/catch blocks around everything. They make for non-linear
>> execution, and I prefer my code to execute in a linear fashion.
>>
>> Paul
>>
> 
> My thoughts exactly.  What do I gain by using a try/catch that I lose by
> using if/else or similar?

you use them not for control flow, but for deferring exceptional application
states, which you can then handle in a small number of places as opposed
to scattering the error handling of unlikely events in all sorts of
disparate places.

there is an art to using them, they compliment 'traditional' error handling,
and I agree they can hinder if used badly.

NB: you can have multiple catch blocks:

try {
	// do lots of stuff
} catch (ConnectException $e) {

} catch (QueryException $e) {

} catch (DBSelectException $e) {

} catch (Exception $e) {
	// catch all for stuff we don't handle specifically
}

> J
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux