News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Reddit.com:
When do you throw exceptions?
September 20, 2013 @ 10:45:04

On Reddit.com there's a discussion that's started up around when to throw exceptions in your PHP applications. The poster asks:

When and where do you throw exceptions? Is it just on database connections? Is it whenever you run a query? Send an email? I'm just curious what the best situations are to throw exceptions and possibly improve my code.

There's a good number of replies so far, some a bit more vague than others:

  • "In exceptional circumstances."
  • "You throw an except when you can't sensibly handle what has just happened."
  • "Fatals for compile-time errors, Exceptions for run-time errors"
  • "I throw an exception any time the function being called is either not capable of continuing or it is not going to return the expected results."
  • "Exceptions everywhere is not a good thing."

Check out more suggestions and comments in the full post.

0 comments voice your opinion now!
exceptions throw opinion conversation

Link: http://www.reddit.com/r/PHP/comments/1mr1qa/when_do_you_throw_exceptions

blog comments powered by Disqus

Similar Posts

Pádraic Brady: Is Facebook’s HHVM Building PHP's Coffin?

Dominic Tancredi: PHP is a dying language - A Rebuttal

Web Developer Juice: 14 descriptive reasons why Ruby is better than PHP

Pádraic Brady's Blog: The Framework Interoperability Group (FIG)

Chris Roane's Blog: 150 Ways to Ruin Your WordPress Site and Your Life


Community Events





Don't see your event here?
Let us know!


language voicesoftheelephpant zendserver framework conference symfony code tips podcast release interview laravel deployment threedevsandamaybe community api series list bugfix introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework