我一直在搜索这个,但我似乎在这段代码中遇到了相同的文章:
try
{
//some code
}
catch(Exception $e){
throw $e;
}
$e 存储在哪里或网站管理员如何查看它?我应该寻找一个特殊的功能吗?
最佳答案
安Exception object (在这种情况下,$e)从 catch{} block 内抛出将被下一个最高的 try{} catch{} block 捕获。
这是一个愚蠢的例子:
try {
try {
throw new Exception("This is thrown from the inner exception handler.");
}catch(Exception $e) {
throw $e;
}
}catch(Exception $e) {
die("I'm the outer exception handler (" . $e->getMessage() . ")<br />");
}
上面的输出是
I'm the outer exception handler (This is thrown from the inner exception handler.)
关于php - PHP 中的异常处理 : where does $e goes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/957223/