default exceptions, interfaces, etc.

php.internals

Sterling Hughes

23 years ago
Hi, Attached is a patch (+ 2 files) that add a default "exception" class to Zend 2. I find this very useful when you just want to throw a simple exception inside of a try {}, but you don't want to create a new exception for each and every error. I'll commit this tommorowish, unless somebody objects. -Sterling
-- "Whether you think you can or think you can't -- you are right." - Henry Ford

Moriyoshi Koizumi

23 years ago
Hi, As per naming convention, I think it'd be nice if the methods were named as: getmessage => get_message getcode => get_code If those are corrected, +1 for this feature. Moriyoshi Sterling Hughes <sterling@bumblebury.com> wrote:

Sterling Hughes

23 years ago
On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote:
> Hi, > > As per naming convention, I think it'd be nice if the methods were > named as: > > getmessage => get_message > getcode => get_code > > If those are corrected, +1 for this feature. >
I was thinking of that - I would personally prefer get_message() and get_code() naming, but that goes against pear's naming conventions, and I want this to integrate well with pear (as a base class.) -Sterling
> Moriyoshi > > Sterling Hughes <sterling@bumblebury.com> wrote: > > > Hi, > > > > Attached is a patch (+ 2 files) that add a default "exception" class to > > Zend 2. I find this very useful when you just want to throw a simple > > exception inside of a try {}, but you don't want to create a new > > exception for each and every error. I'll commit this tommorowish, > > unless somebody objects. > > > > -Sterling > > -- > > "Whether you think you can or think you can't -- you are right." > > - Henry Ford
-- "People can have the Model T in any colour -- so long as it's black." - Henry Ford

Moriyoshi Koizumi

23 years ago
Okay, then I see the issue and no problem with the patch. +1. Moriyoshi Sterling Hughes <sterling@bumblebury.com> wrote:

Derick Rethans

23 years ago
On Sun, 22 Mar 2003, Sterling Hughes wrote:
> On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote: > > Hi, > > > > As per naming convention, I think it'd be nice if the methods were > > named as: > > > > getmessage => get_message > > getcode => get_code > > > > If those are corrected, +1 for this feature. > > > > I was thinking of that - I would personally prefer get_message() and > get_code() naming, but that goes against pear's naming conventions, and > I want this to integrate well with pear (as a base class.)
It's a PHP function, not PEAR code, so it should follow the PHP naming style. Derick
-- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------

Sterling Hughes

23 years ago
On Sat, 2003-03-22 at 21:33, Derick Rethans wrote:
> On Sun, 22 Mar 2003, Sterling Hughes wrote: > > > On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote: > > > Hi, > > > > > > As per naming convention, I think it'd be nice if the methods were > > > named as: > > > > > > getmessage => get_message > > > getcode => get_code > > > > > > If those are corrected, +1 for this feature. > > > > > > > I was thinking of that - I would personally prefer get_message() and > > get_code() naming, but that goes against pear's naming conventions, and > > I want this to integrate well with pear (as a base class.) > > It's a PHP function, not PEAR code, so it should follow the PHP naming > style. >
As I mentioned to Marcus, there are no naming conventions for OO code, only procedural code (in PHP). Also, compliance with PEAR is a pragmatic solution, because presumably all their code will be inheriting from Exception. The largest, and the official OO library should be in-sync with standard practices (and we have none yet regarding OO code.) -Sterling
> Derick
-- "A business that makes nothing but money is a poor kind of business." - Henry Ford

Jani Taskinen

23 years ago
On 22 Mar 2003, Sterling Hughes wrote:
>On Sat, 2003-03-22 at 21:33, Derick Rethans wrote: >> On Sun, 22 Mar 2003, Sterling Hughes wrote: >> >> > On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote: >> > > Hi, >> > > >> > > As per naming convention, I think it'd be nice if the methods were >> > > named as: >> > > >> > > getmessage => get_message >> > > getcode => get_code >> > > >> > > If those are corrected, +1 for this feature. >> > > >> > >> > I was thinking of that - I would personally prefer get_message() and >> > get_code() naming, but that goes against pear's naming conventions, and >> > I want this to integrate well with pear (as a base class.) >> >> It's a PHP function, not PEAR code, so it should follow the PHP naming >> style. >> > >As I mentioned to Marcus, there are no naming conventions for OO code, >only procedural code (in PHP). Also, compliance with PEAR is a >pragmatic solution, because presumably all their code will be inheriting >from Exception. The largest, and the official OO library should be >in-sync with standard practices (and we have none yet regarding OO >code.)
Even if we don't have specific rules (yet) for OO stuff, IMO, it should follow the existing rules. --Jani

(Marcus Börger)

23 years ago
At 00:43 23.03.2003, Sterling Hughes wrote:
>On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote: > > Hi, > > > > As per naming convention, I think it'd be nice if the methods were > > named as: > > > > getmessage => get_message > > getcode => get_code > > > > If those are corrected, +1 for this feature. > > > >I was thinking of that - I would personally prefer get_message() and >get_code() naming, but that goes against pear's naming conventions, and >I want this to integrate well with pear (as a base class.)
I agree with moriyoshi here. If pear has a problem with that - than please change pear and do not add more inconsistent featrures instead. The exception class itself was not only once requested. Another point however is the function name zend_register_default_interfaces() in the C code. Since we have interfaces and you do not register an interface with that function you are missleading here so please name that function something like zend_register_default_exceptions() and change the filenames to contain the word exception instead of interfaces. regards marcus

Sterling Hughes

23 years ago
On Sat, 2003-03-22 at 21:14, Marcus Börger wrote:
> At 00:43 23.03.2003, Sterling Hughes wrote: > >On Sat, 2003-03-22 at 19:02, Moriyoshi Koizumi wrote: > > > Hi, > > > > > > As per naming convention, I think it'd be nice if the methods were > > > named as: > > > > > > getmessage => get_message > > > getcode => get_code > > > > > > If those are corrected, +1 for this feature. > > > > > > >I was thinking of that - I would personally prefer get_message() and > >get_code() naming, but that goes against pear's naming conventions, and > >I want this to integrate well with pear (as a base class.) > > > I agree with moriyoshi here. If pear has a problem with that - than please > change > pear and do not add more inconsistent featrures instead. The exception class > itself was not only once requested. >
Well, Moriyoshi agreed with me, once he understood the rationale. So, its only you. :) As for inconsistency, PEAR is the standard for OO php code, and studlyCaps are a part of their standards. PHP standards exist for procedural code, which is a different beast.
> Another point however is the function name zend_register_default_interfaces() > in the C code. Since we have interfaces and you do not register an > interface with > that function you are missleading here so please name that function something > like zend_register_default_exceptions() and change the filenames to contain the > word exception instead of interfaces. >
No, you misunderstand the purpose. The idea of this file is to add any standard classes, interfaces, etc. Exception just happens to be the first practical example. -Sterling
> regards > marcus
-- "Reductionists like to take things apart. The rest of us are just trying to get it together." - Larry Wall, Programming Perl, 3rd Edition