workerman 下使用 set_exception_handler 无效

stephen

发现 workerman 下使用 set_exception_handler 设置异常捕捉无效

但在try...catch中可以捕捉,nginx fastcgi里面 set_exception_handler 正常,是什么原因?

<?php

use \BadFunctionCallException as BadFunctionCallException;
use \BadMethodCallException as BadMethodCallException;
use \DomainException as DomainException;
use \InvalidArgumentException as InvalidArgumentException;
use \LengthException as LengthException;
use \LogicException as LogicException;
use \OutOfBoundsException as OutOfBoundsException;
use \OutOfRangeException as OutOfRangeException;
use \OverflowException as OverflowException;
use \RangeException as RangeException;
use \RuntimeException as RuntimeException;
use \UnderflowException as UnderflowException;
use \UnexpectedValueException as UnexpectedValueException;

// 下面的方法在workerman无效,但在fastcgi有效。
set_exception_handler('exception_handler');

function exception_handler($e)
{
    // var_dump($e);
    echo '123';
}

// 以下代码 workerman 中有效
// try{
//     new t;
// }catch(Exception $e){
//     echo $e->getMessage();
// }

class t{
    function __construct()
    {
        throw new BadMethodCallException('test');
    }
}

new t;
3658 1 0
1个回答

walkor

对,workerman里不支持set_exception_handler。

年代过于久远,无法发表回答
🔝