NYCPHP Meetup

NYPHP.org

[nycphp-talk] If/else vs Try/catch

Greg Rundlett greg.rundlett at gmail.com
Wed Nov 28 21:33:17 EST 2007


On Nov 28, 2007 8:53 PM, Daniel Convissor
<danielc at analysisandsolutions.com> wrote:
> Hi Ben:
>
> On Wed, Nov 28, 2007 at 01:33:42PM -0500, Ben Sgro (ProjectSkyLine) wrote:
> >
> > Which allows to me handle Exceptions two ways, one for internal logging
> > and one for display to the user. I'll read the link you posted as well.
>
> Or you can do what we do on my job.  We use one exception class.  What it
> does upon exception depends on settings.  It can log, email, or print.
> Another setting is used to indicate whether or not the backtrace should
> be included in the debug output.
>
> --Dan
>

For a good look at reusable code for exception handling in PHP, look
at PEAR.  The exception-handling class is a feature of the base 'PEAR'
package

http://pear.php.net/package/PEAR
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/Exception.php?view=markup
http://pear.php.net/package/PEAR/docs/latest/PEAR/PEAR_Exception.html

(note to newbies/all in the early days, it used to be called the PEAR
'Error' class, so don't be confused if you find some older tutorials
etc. describing that.  With the release of PHP5 three years ago, we
got exceptions, and so now the PEAR Exception class supercedes the
former.)




> ... snip ...
>
> --
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>             data intensive web and database programming
>                 http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
> _______________________________________________
>
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



-- 
A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?



More information about the talk mailing list