PHPとZend Frameworkでの前の例外



私の見てるマニュアルには載ってますよ!
http://framework.zend.com/manual/ja/zend.exception.previous.html


Zend Frameworkを使ってる方は、PHP5.2でもprevious exceptionを可能にするために以下のとおり変更が施されて、codeは(int)キャストしてることに注意。
http://framework.zend.com/code/browse/Standard_Library/standard/trunk/library/Zend/Exception.php

ちなみに、

<?php
require_once 'Zend/Exception.php';

function throwing() {
    throw new InvalidArgumentException();
}

function get() {
    throwing();
}   
    
try {   
    try {
        get();
    } catch (Exception $e){
        throw new Zend_Exception("", 10, $e);
    }
} catch (Exception $e) {
    echo $e;
    echo PHP_EOL.'----'.PHP_EOL;
    var_dump($e->getTraceAsString());
    var_dump($e->getPrevious()->getTraceAsString());
}

を実行すると、

exception 'InvalidArgumentException' in /tmp/previous_test.php:5
Stack trace:
#0 /tmp/previous_test.php(9): throwing()
#1 /tmp/previous_test.php(14): get()
#2 {main}

Next exception 'Zend_Exception' in /tmp/previous_test.php:16
Stack trace:
#0 {main}
----
string(9) "#0 {main}"
string(87) "#0 /tmp/previous_test.php(9): throwing()
#1 /tmp/previous_test.php(14): get()
#2 {main}"

となる。で、これが実運用上ロギングとのかねあいでうんにゃこりゃがあると思いますが、僕Javaってなんじゃばなので一家言ありません。。(Zend Serverー?)


PHPマニュアルのException:
http://www.php.net/manual/ja/exception.construct.php