Re: When to use exception, or When not to use exception

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

 



On Wed, February 21, 2007 10:28 am, js wrote:
> Recently I upgraded my dev environment and started to use PHP5 at
> last!
> Compared with the former one, PHP5 rocks in many ways.
> So I love it so much, but sadly, I don't exactly know when to use
> exception.
> I'm never used to use Java, or languages that support exceptin
> so I have to learn the usage..
>
> So, my question is
> When to use, or when not to use exception?
> Now I'm using exception in 99% to handle errors because it's easier
> and cleaner.
> The only problem I have using exception instead of normal
> "if-error-then" method is
> that I have to define logs of Exception-derived classes to effectively
> handling erros.
> It's cumbersome but not so bad compared with traditional error
> handling.

If you like defining lots of classes, then always use exceptions.

If you find that it's even more cumbersome than traditional error
handling, then stop using them entirely.

You really want to avoid having too many different error handling
mechanisms, as that just makes a pig's breakfast of everything.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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