stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors


Catching Uncaught Exceptions







Catching Uncaught Exceptions

Catching Uncaught Exceptions 06/10/2004 09:46 AM

Continuing my belief that the best way to learn the fine art of programming is to learn from your better looking neighbours, here's a very interesting article on using exceptions in Java that can be applied to PHP5. Dr Kabutz (love the name), gives several excellent real-world examples of how hard it is to handle exceptions.

Of course there are exceptions to the exceptions. Don't use an exception when:

  • the error is not really an error, but a change of state, such an end-of-file condition. Confusing this point is the most common beginner mistake.

  • you want to write obfusticated code because your job has been made redundant :-)

  • the error is so difficult to fix that you have to write custom code at the point the error occurred.

  • you're still using PHP3, and planning to upgrade to PHP4 next year :-)

  • you are doing something mission-critical, and you want to enumerate and handle every possible error where it occurs, to ensure safety and timeliness.

  • your very experienced boss tells you that it's better to return an error code that is ignored than raise an exception that is ignored :-)

tri: Dou g Ross opinion on exceptions, and my response. I also stumbled onto Jeff's response while browsing around.




This is a GrokNews Entry: (what is grok?)





Similar Items

Catching Uncaught Exceptions

Grok Headline matches for Catching Uncaught Exceptions

There are no exceptions to Postel's Law


There are no exceptions to Postel's Law 01/09/2004 10:14 PM
Specs are things with important-sounding words like "W3C Recommendation", "RFC 2616", or "ISO 8879" at the top. Weblogs are things with cat pictures at the top. (1162 words)

Silly exceptions


Silly exceptions 09/05/2004 02:40 PM
First official release!

With Few Exceptions, the String Remains
the Same


With Few Exceptions, the String Remains
the Same
08/30/2004 01:00 AM
Professional and recreational players are unlikely to see major developments in racket string technology any time soon.

Exceptions in C 0.1.5 (Default branch)


Exceptions in C 0.1.5 (Default branch) 04/10/2005 02:40 PM
Exceptions in C implements powerful and customizable exceptions for the C programming language. This is done using non-local jumps. It started as a hack, but could be used in real-world applications.
Changes:
One essential macro was renamed due to compatibility issues with the C library. A few customization-dependent bugs were also fixed. Clearer examples were added and the distribution build was fixed (it lacked one file in the previous release.)

Feds grant DMCA exceptions


Feds grant DMCA exceptions 10/29/2003 12:10 AM
The U.S. Library of Congress creates four narrow exemptions to a controversial digital-piracy statute but is criticized by free-speech activists, who had hoped for more exceptions.

Return-codes vs. Exceptions, Part 129


Return-codes vs. Exceptions, Part 129 05/24/2004 12:27 PM
Doug Ross, CTO of BadBlue (which sells a mean web server that runs PHP), has a nice recap of the debate on how to handle errors. Should we use error codes or exceptions? Doug weaves a nice story around several people's opinions. I totally agree with Doug with regards to real-time software (you want to handle the error as soon as possible with an error code).

However that's not the way I would want to write financial code nowadays. With the relational databases we now use, I'm more likely to throw an exception and perform a database rollback in the exception handler. I think that database advances with commit/rollback make resource cleanup sufficiently trivial for us to use generic exceptions.


Preble's mouse exceptions permanent


Preble's mouse exceptions permanent 05/19/2004 10:27 PM
AP via New Jersey Online May 20 2004 2:51AM GMT

Adding Windows Update addresses to the
proxy settings exceptions list


Adding Windows Update addresses to the
proxy settings exceptions list
05/05/2004 04:50 PM

Catching up with...


Catching up with... 12/19/2004 02:52 PM
Wow... it's been quite a while since my last post! Things have been quite busy. To bring things up to...

Still catching up


Still catching up 04/09/2004 04:03 PM

As noted earlier, a pinched nerve in my neck is making it very hard for me to type - in fact, for the past several days I haven't been able to type for more than five minutes at a time. Somehow, though, I'm almost caught up with my email, but many questions in the support newsgroups remain unanswered. I hope to handle them all this week, but it all depends on how much longer it takes to recover.

I've been seeing a physical therapist for a few weeks, but the results haven't been good so tomorrow I'm visiting a chiropractor for the first time in my life. Wish me luck :)


Catching up


Catching up 06/29/2004 03:48 PM

lily pads

I've got a bunch of pictures to catch up on and scan in, as well as photos from Juhannus coming later this week, so the people who seem to like my pictures have something to look forward to in the coming week.


Catching the Hot Potatoes


Catching the Hot Potatoes 03/23/2005 03:49 PM
Protect your portfolio from the worst of a company's stumbles.

Catching up with Harry


Catching up with Harry 02/17/2004 11:57 PM

I'm not sure how I missed this, but Harry Fueck's new book The PHP Anthology was published by SitePoint back in December, as a hefty 2 volume epic. Harry is the guru behind PHP Patterns and really knows his stuff. While the book is at first glance a cookbook for solving web related problems, Harry also uses it as a platform for teaching sensible development practises:

Between the lines I've focused on teaching OOP by example, partly by developing classes in the book and also by taking advantage of Open Source class libraries I'm familiar with; in most cases projects from PEAR.

That's also where I'd say The PHP Anthology is unique, in it aims to get readers to avoid re-inventing wheels already done many times in PHP. Although many of the subjects have been seen before (often online), the focus here is either to use an Open Source class library or put one together, solving a problem once and for all, as opposed a hacked script that goes half way.

Sample chapters from the books are available online, including an excellent explanation of caching techniques. Harry is also one of my co-bloggers over at SitePoint where he writes about (you guessed it) PHP in Dynamically Typed.


Catching a Virus in the Act


Catching a Virus in the Act 09/18/2004 05:21 AM
Scientists get their first look at a virus attaching to DNA. Physical proof of this surprising interaction could lead to drugs that can stop some infections. By Kristen Philipkoski.

An eye-catching phone


An eye-catching phone 04/11/2004 09:04 PM
ZDNet Apr 12 2004 0:34AM GMT

Catching up to cable


Catching up to cable 03/31/2005 03:24 AM
Usatoday.com - Wed Mar 30, 08:45 pm GMT

Coors Catching Up


Coors Catching Up 04/22/2004 04:15 PM
The nation's No. 3 brewer posts increased earnings on strong international results.

Spider Catching in ASP


Spider Catching in ASP 12/14/2002 07:41 AM
WebmasterBase Dec 14 2002 6:47AM ET

Catching Up With The Rocket Guy


Catching Up With The Rocket Guy 10/29/2003 07:11 PM
Jedi Holocron writes "The full article is at Space.Com and reports on the current status of Brian "Rocket Guy" Walker's home-brew space program. This is the ...

Catching the wave?


Catching the wave? 05/28/2004 01:56 AM
USA Today May 28 2004 5:45AM GMT

Why isn't Froogle Catching on?


Why isn't Froogle Catching on? 08/01/2004 10:06 AM
"...people are saying Froogle is a major disappointment. ... the big question is why? Was it solely their implementation? Or is there more to it?"

Catching a Virus Writer


Catching a Virus Writer 06/04/2004 05:57 AM

Catching the nano wave


Catching the nano wave 09/17/2004 06:37 AM
CNET News.com's Charles Cooper says getting funding for the nanotechnology Manhattan Project is the right idea. But is anybody listening?

Push-to-talk catching on


Push-to-talk catching on 06/03/2004 06:50 PM
ZDNet Jun 3 2004 10:23PM GMT

Eye-catching wireless technology


Eye-catching wireless technology 09/13/2004 10:42 AM
San Jose Mercury News Sep 13 2004 2:14PM GMT

Clark is catching up to Kerry


Clark is catching up to Kerry 01/04/2004 07:20 AM
his flameout in NH .. daily tracking poll

americanresearchgroup.com/nhpoll/demtrack
track this site | 5 links


Catching Errors Before They Catch You


Catching Errors Before They Catch You 12/04/2002 10:10 AM

Catching the Pattern Wave


Catching the Pattern Wave 01/13/2003 08:08 PM
Catching the Pattern Wave Like Jeremy I'm starting to get the whole pattern gig (starting). All it took was using Harry's wonderful strategy pattern for validation (which I've extended a bunch of ways already). Now Harry has another one: Observers. The Observer Pattern is designed to help cope with one to many relationships between objects, allowing changes in an object to update many associated objects. It provides a powerful mechanism to extend our applications, in terms of how they respond to events, without needing alter existing (and working) code. We'll take a simplified look at how the observer pattern might be used in a typical PHP forum application then suggest other uses for the observer pattern ... The Observer pattern is defined by the Gang of Four in Design Patterns as behavioural pattern - that is one we can use to modify the behaviour of our applications. It's regarded as being so useful, that Sun bothered to implement it in the Java API (see Observable and Observer). The basic principle behind the observer pattern is if you have some object, such as a Post object for a forum system, you can have other objects, such as a Mailer object, act as an observer and respond to any changes in the Post object, such as emailing relevant forums users that a new post has been added to the thread they were subscribed to. Conceptually, the Observer pattern in something like a trigger in a database, which runs a stored procedure when a table row is modified for example (we won't go too far with this analogy though). Normally we might implement the mailing functionality in the Post object itself but what if later we want add further "events" to Post, when a new post is made, such as adding an entry to our forums RSS feed for example? And how many more things might we want to add in future? The observer pattern provides us the mechanism to add such functionality without needing to alter the Post object. [_Go_] Have I fully read this through, tried it out, etc? No. Will I? Almost certainly.

Catching Up With Dick Tracy


Catching Up With Dick Tracy 03/20/2003 08:33 AM
How watchmaker Fossil teamed up with Microsoft and Palm to create the wearable computer techies have longed for since the dashing cartoon detective flashed his telephone wristwatch. By Josh McHugh from Wired magazine.

I thee Web: Net sites catching on


I thee Web: Net sites catching on 12/02/2003 10:23 PM
Canadian Press via Canada.com Dec 2 2003 9:03PM ET

Groceries Online Catching On In NYC


Groceries Online Catching On In NYC 04/06/2005 09:36 PM
The online grocery market has certainly gone through its share of ups and downs . However, over the past few years there have been a bunch of stories about a next generation of online grocery stores that seem to be getting more traction. One of the more famous is FreshD irect in New York City -- where online grocery shopping makes a lot more sense. Apparently, residents there agree, as a new study shows that more than half of NYC residents have tried online groceries -- though, that doesn't mean they all have been happy with it. Still, it does suggest that there's demand for such a service in some places (especially urban), if it's done right.

Catching Light In A Bottle


Catching Light In A Bottle 12/11/2003 02:43 AM
Apparently, some physicists have come up with a way to bri ng light to a screeching halt - if only for a tiny fraction of a second. It's believed this may be helpful in creating quantum computers (though, many people are still wondering if quantum computers will ever get anywhere. Of course, the bad joke on this is that maybe the problem is that they're trying to create quantum computers, which means they will never work. It's only when they don't try to create quantum computers that they will work...). You may recall that some physicists claimed to have stopped light in its tracks back in 2001. Apparently, that was nothing compared to what just happened, but my physics is a bit too rusty to understand the difference.

Internet banking catching on


Internet banking catching on 03/24/2005 12:16 PM
thestar.com.my Mar 24 2005 3:50PM GMT

Catching up with crooks online


Catching up with crooks online 04/12/2005 10:55 AM
Freep.com - Tue Apr 12, 11:44 am GMT

Catching the credit card thieves


Catching the credit card thieves 03/25/2005 09:11 PM
Curtis Poe got his credit cards stolen: This morning, I found out that thousands of dollars of charges had been made on two of my credit cards in the past two days. Now, the identity thieves are sitting in jail. This is how it happened. It involves identity theft, a careless thief, one pissed-off Ovid and lots of luck. Awesome!...

Eye-catching wireless technology
(SiliconValley.com)


Eye-catching wireless technology
(SiliconValley.com)
09/13/2004 12:37 PM
SiliconValley.com - SAN DIEGO - For two days last week, companies from around the globe converged near San Diego to showcase their best products and services using mobile and wireless technology.

'Podcasts' Catching on with iPod Owners


'Podcasts' Catching on with iPod Owners 04/07/2005 03:26 AM
ZDNet Apr 7 2005 7:35AM GMT

Catching Up With Dark Horse Comics


Catching Up With Dark Horse Comics 06/05/2005 11:51 PM
I just picked up the latest pair of Star Wars comics from Dark Horse. One series interrupts its current storyline, while the other wraps up its run. Find out what's inside each issue.

Catching the Online Cartoon Virus


Catching the Online Cartoon Virus 03/14/2005 06:15 PM
Organizations as disparate as Burger King and Greenpeace are producing offbeat Internet video clips, hoping they will gain popularity on the Web.
Grok Description matches for Catching Uncaught Exceptions
GrokA matches for Catching Uncaught Exceptions

Catching Uncaught Exceptions

The following phrases have been identified by the grok system as matching this entry:

















Also check out:


Grok

Ipod Porn on the
Rise

Brief Abstract of
Wikipedia's
Mesothelioma Cancer
page

Get first aid
instructions in your
cell phone

IE is crap
JSPWiki gains
podcasting support

Search Engine Watch
Adds Forums

Chemicals In
Cosmetics -- The
Database

Rome 0.1
KQEmu 0.1
RadSpool 0.14
MyPasswordSafe 0.6.1
(Development)

epto 0.8.4
S.Korean anti-trust
watchdog probes
Microsoft affiliate

Aperto WMAN deals in
France and Ireland

US punters face
higher phone charges

Unpatched IE vuln
exploited by adware

Copy protection to
extend to multiple
but limited burns

MS boffins build
real-time stereocam

Opera launches 250%
go-faster for mobile
phone browser

Cassini closes in on
strange moon

Husband hunted over
freezer body

Tennis: Flanagan
beaten

Cricket: England v
NZ

Re: unauthorized
deletion of IPsec
SAs in isakmpd,
still

Gmail Invitation
Market Bottoms Out

Browser Page
Rendering

Stocks Edge Higher
on Unemployment
Report (AP)

Chip Off the Old H&R
Block

A Cautious
Ameritrade

Coke Says Bye to
Heyer

What Your IRA Can Do
The Little TiVo That
Could

Shifty Trades at
Swift

Profiting From My
Mistakes

OTC Millennium
Falcon At Hasbro

Hasbro Officially
Announces Jedi High
Council

If this works, I'll
be releasing another
MT patch this
afternoon

Iraq Government to
Surmount Kurd
Discontent--Allawi
(Reuters)

Rumsfeld May Extend
Scope of Iraq Abuse
Probe (Reuters)

Yankees Win, but
Kevin Brown Injured
(AP)

Research Shows Dogs
Understand Language
(AP)

Jobless Claims Up
but Recovery Still
Seen (AP)

FixYourOwnPrinter.co
m

Bantha Tracks Goes
Online

Purdue Mathematician
Claims Proof for
Riemann Hypothesis

Scientology link to
public schools / As
early as the third
grade, students in
S.F. and elsewhere
are subtly
introduced to
church's concepts
via anti-drug
teachings

CCR
follow the wishes of
his wife

spOre [products]
Kerry's lead widens
Guardian Unlimited |
Special reports |
Bush opens new rift
over Middle East
plan

VOIP's Cry: More
Secure Data Nets

Ask Jeeves Files To
Issue More Stock

The Advertising and
Marketing of Gmail

US-based software
company buys Indian
outsourcing firm
(AFP)

what is grok?