fetus Diary

2007/09/21(金) - re-throw

<?php
    class TestException extends Exception {
    }
    
    try {
        try {
            throw new TestException('hoge');
        } catch(Exception $e) {
            printf("catch exception '%s' at %s line %d, msg: %s\n",
                        get_class($e),
                        basename(__FILE__), __LINE__,
                        $e->getMessage());
            throw $e;
        }
    } catch(Exception $e) {
            printf("catch exception '%s' at %s line %d, msg: %s\n",
                        get_class($e),
                        basename(__FILE__), __LINE__,
                        $e->getMessage());
    }
?>
[******@kobora ~]$ php hoge.php
catch exception 'TestException' at hoge.php line 11, msg: hoge
catch exception 'TestException' at hoge.php line 18, msg: hoge

PHP のマニュアルで特に言及が無い点を見ると、これで正解? C++ みたいに特殊構文は無し、かな?

コメント

コメントはありません。

名前
メール
コメント

※HTML タグは使えません。HTTP URL には自動リンクが張られます。

Captcha
画像から読み取れる文字を入力: