Re: Re[2]: Return or not to return, that is the question

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

 



On Wed, May 30, 2007 12:00 pm, Paul Novitski wrote:
[snip] use the archives

I think there is a LOT of value in bubbling up errors to the
appropriate level of handling, and letting the right layer do the
right job for the error.

HOWEVER: it is not a good idea, imho, to "always" let the errors
bubble up to the outer layer, which is what Paul seemed to have
typed...

The problem with that approach is that you end up being painted into a
corner where your application can do little more than print "It
broke." because the low-level context is not available to the caller
of the function.

The lowest layers of your application should be logging very precise
info about the error for the developer, with code for every possible
error condition you can think of, and hopefully defaults for error
conditions you can't think of.

The middle layers might return a smaller set of common error
codes/messages.

The outer layer might lookup error codes to print suitable end-user
messages, or translate with gettext or...

In an ideal world, the outer layer presents the end user with
something meaningful to them, while providing an error code or unique
identifier that a developer can use to locate the detailed info needed
to fix the problem.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie 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