xref: /PHP-8.2/tests/lang/035.phpt (revision 902d6439)
1--TEST--
2ZE2: set_exception_handler()
3--FILE--
4<?php
5class MyException extends Exception {
6    function __construct(public $error) {}
7
8    function getException()
9    {
10        return $this->error;
11    }
12}
13
14function ThrowException()
15{
16    throw new MyException("'This is an exception!'");
17}
18
19
20try {
21} catch (MyException $exception) {
22    print "There shouldn't be an exception: " . $exception->getException();
23    print "\n";
24}
25
26try {
27    ThrowException();
28} catch (MyException $exception) {
29    print "There was an exception: " . $exception->getException();
30    print "\n";
31}
32?>
33--EXPECT--
34There was an exception: 'This is an exception!'
35