1--TEST--
2ZE2 errors caught as exceptions
3--FILE--
4<?php
5
6class MyException extends Exception {
7	function __construct($_errno, $_errmsg) {
8		$this->errno = $_errno;
9		$this->errmsg = $_errmsg;
10	}
11
12	function getErrno() {
13		return $this->errno;
14	}
15
16	function getErrmsg() {
17		return $this->errmsg;
18	}
19}
20
21function ErrorsToExceptions($errno, $errmsg) {
22	throw new MyException($errno, $errmsg);
23}
24
25set_error_handler("ErrorsToExceptions");
26
27// make sure it isn't catching exceptions that weren't
28// thrown...
29
30try {
31} catch (MyException $exception) {
32	echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
33}
34
35try {
36	trigger_error("I will become an exception", E_USER_ERROR);
37} catch (MyException $exception) {
38	echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
39}
40
41?>
42--EXPECT--
43There was an exception: 256, 'I will become an exception'
44