Req #55542 [Asn]: SNMP class should use Exceptions instead of PHP Errors

From: Date: Fri, 02 Sep 2011 18:52:38 +0000
Subject: Req #55542 [Asn]: SNMP class should use Exceptions instead of PHP Errors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-163260@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55542&edit=1

 ID:                 55542
 Updated by:         lytboris@php.net
 Reported by:        ch@php.net
 Summary:            SNMP class should use Exceptions instead of PHP
                     Errors
 Status:             Assigned
 Type:               Feature/Change Request
 Package:            SNMP related
 PHP Version:        5.4.0alpha3
 Assigned To:        lytboris
 Block user comment: N
 Private report:     N

 New Comment:

Here it is thread in PHP-DEV I mentioned:
http://marc.info/?l=php-internals&m=129853991816725
Unless something changes I would prefer to techniques described there.


Previous Comments:
------------------------------------------------------------------------
[2011-09-02 12:05:43] ch@php.net

But PDO has a history back to PHP4 or the days where people where used to check every single return
value for PEAR_Error. The SNMP class is new and could lead as good example for proper OOP style!

(Or do you prefer C style $errno checking after every method call over try/catch statements? The
chances that an error goes unnoticed is much lower with exceptions.)

------------------------------------------------------------------------
[2011-09-02 11:48:34] lytboris@php.net

enable SNMP::ERRNO_ANY by default is not a good idea I think. PDO has the same default behavior for
throwing exceptions.

------------------------------------------------------------------------
[2011-09-02 10:41:20] ch@php.net

Thanks for implementing this so quickly. But the constructor still says:
"snmp_object->exceptions_enabled = 0;", as this is a class one would rather expect OOP
style exceptions as default, or?

------------------------------------------------------------------------
[2011-09-02 10:13:21] lytboris@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

A new SNMP object property is introduced: exceptions_enabled.
Setting this property to ORed combination of SNMP::ERRNO_* errors will enable exception throwing on
these errors. SNMP::ERRNO_ANY may be used to enable all posslible SNMP::ERRNO_* errors at once.

------------------------------------------------------------------------
[2011-09-02 10:13:19] lytboris@php.net

Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=316032
Log: merge from trunk
added SNMPException class, enabling ability to throw exceptions
when a known SNMP error has occured
FR #55542

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=55542


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55542&edit=1


Thread (7 messages)

« previous php.bugs (#163260) next »