Annotation of embedaddon/php/tests/lang/error_2_exception_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ZE2 errors caught as exceptions
! 3: --SKIPIF--
! 4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: class MyException extends Exception {
! 9: function MyException($_errno, $_errmsg) {
! 10: $this->errno = $_errno;
! 11: $this->errmsg = $_errmsg;
! 12: }
! 13:
! 14: function getErrno() {
! 15: return $this->errno;
! 16: }
! 17:
! 18: function getErrmsg() {
! 19: return $this->errmsg;
! 20: }
! 21: }
! 22:
! 23: function ErrorsToExceptions($errno, $errmsg) {
! 24: throw new MyException($errno, $errmsg);
! 25: }
! 26:
! 27: set_error_handler("ErrorsToExceptions");
! 28:
! 29: // make sure it isn't catching exceptions that weren't
! 30: // thrown...
! 31:
! 32: try {
! 33: } catch (MyException $exception) {
! 34: echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
! 35: }
! 36:
! 37: try {
! 38: trigger_error("I will become an exception", E_USER_ERROR);
! 39: } catch (MyException $exception) {
! 40: echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
! 41: }
! 42:
! 43: ?>
! 44: --EXPECT--
! 45: There was an exception: 256, 'I will become an exception'
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>