1--TEST--
2ZE2 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
8class 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
23function ErrorsToExceptions($errno, $errmsg) {
24	throw new MyException($errno, $errmsg);
25}
26
27set_error_handler("ErrorsToExceptions");
28
29// make sure it isn't catching exceptions that weren't
30// thrown...
31
32try {
33} catch (MyException $exception) {
34	echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
35}
36
37try {
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--
45There was an exception: 256, 'I will become an exception'
46