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

From: Date: Fri, 02 Sep 2011 10:13:21 +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-163239@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
+Status:             To be documented
 Type:               Feature/Change Request
 Package:            SNMP related
 PHP Version:        5.4.0alpha3
 Assigned To:        lytboris
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[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

------------------------------------------------------------------------
[2011-09-02 10:04:08] lytboris@php.net

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

------------------------------------------------------------------------
[2011-08-30 22:15:06] ch@php.net

Description:
------------
Hello

Subject says all, IMHO it does not make sense to start writing a new class that does not use 100%
exceptions.

This bug is a follow up on #40816 which ended with:

 [2011-08-30 15:18 UTC] lytboris@php.net

> I have read a bunch of threads on php-dev about extensions throwing exceptions and the last
> thing I remember that extension should not throw any exception except object creation if there is no
> way to disable them.

> Anyway, if to throw exceptions, library will throw an exception for each error, not only
> parsing error.


Please, please, convinced yourself that Exceptions are cool and worth refactoring the code. I'd
be willing to help with writing tests :)

I'd be curious about the threads you mentioned (a quick google found nothing but then the
keywords are very common) but there are already some extensions (spl/php_spl.c, mysql/php_mysql.c,
reflection/php_reflection.c) that do throw Exceptions.




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



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


Thread (7 messages)

« previous php.bugs (#163239) next »