php中的Throwables和ParseError

<?php
//Throwables
//ParseError

try {
    include 'config.php';
} catch (\ParseError $e) {
    echo 'ParseError handling';
    echo '<br/>';
}

class Address {
    private $customer;
    public function __construct(Customer $customer) {
        $this->customer = $customer;
    }
}

$customer = new stdClass();

try {
    $address = new Address($customer);
} catch (\Throwable $t) {
    echo 'Throwable handling';
    echo '<br/>';
} finally {
    echo 'cleanup';
    echo '<br/>';
}

?>

输出

ParseError handling
Throwable handling
cleanup

 

上一篇:如何在Java中的自定义异常中设置我自己的消息,可以检索我的getMessage()但是没有使用构造函数,有什么办法吗?


下一篇:在Java中自定义异常中的字段序列化