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

 ID:                 40816
 Updated by:         [email protected]
 Reported by:        ch at westend dot com
 Summary:            Add "snmptranslate" function
-Status:             Assigned
+Status:             Feedback
 Type:               Feature/Change Request
 Package:            SNMP related
 Operating System:   linux
 PHP Version:        5.2.1
 Assigned To:        lytboris
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2011-08-30 15:10:48] ch at westend dot com

Now the following works..

  @$snmp->get(array($oid1, $oid2));
  if ($snmp->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR) {
    throw new Exception($snmp->getError());
  }

... but why is there only a warning? Calling get() with a OID that does not 
even parses should throw an Exception? Especially as when using OOP, one does 
not expect having to call getErrno() after every call as we did in the last 
millenium or even worse don't catch this error.

Can you wrapt this into a nice SnmpOidParsingException?

------------------------------------------------------------------------
[2011-08-30 14:30:34] [email protected]

Indeed. Commited sources into PHP_5_4 branch.

------------------------------------------------------------------------
[2011-08-30 09:52:01] ch at westend dot com

As of SVN revision 315762 from now, the constant only appears in the tests, not 
in the class source. Running the tests yield to:

Fatal error: Undefined class constant 'ERRNO_OID_PARSING_ERROR' in 
/home/chammers/workspace/php-src-5.4/ext/snmp/tests/snmp-object-errno-errstr.php
 on line 45

Maybe it's not yet committet?

------------------------------------------------------------------------
[2011-08-30 09:42:08] [email protected]

Please check that you have ERRNO_OID_PARSING_ERROR in snmp extension sources. 
This constant appeared on 27th of august.

------------------------------------------------------------------------
[2011-08-30 09:21:17] ch at westend dot com

The idea sounds good but it does not seem to work. The "Invalid object 
identifier" is thrown only as PHP Warning, not set in SNMP->error:


 $ cat test.php 
 <?php
        $snmp = new SNMP(SNMP::VERSION_1, 'localhost', 'public', 0, 0);
        $oid1 = 'IF-MIB::ifAlias.1';
        $oid2 = 'DOES-NOT-EXIST-MIB::FOO';
        $oid3 = 'NOTIFICATION-LOG-MIB::nlmConfigGlobalEntryLimit.0';
        $snmp->get(array($oid1, $oid2, $oid3));
        printf("-------\n%s (%d)\n--------\n", $snmp->getError(), $snmp->errno);




 $ ../php-src-5.4/sapi/cli/php -d include_path=.:/usr/share/php  test.php 
 Warning: SNMP::get(): Invalid object identifier: DOES-NOT-EXIST-MIB::FOO in  
/home/chammers/workspace/php_test/test.php on line 8
 -------
  (0)
 --------

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


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=40816


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

Reply via email to