直接抛出异常报错500
<?php
namespace app\controller;
class IndexController
{
public function test(){
throw new \Exception(111,405);
}
}
#### 截图报错信息里报错文件相关代码
Exception: 111 in G:\project\php\demo\webman-api\app\controller\IndexController.php:10
Stack trace:
#0 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\App.php(319): app\controller\IndexController->test()
#1 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\App.php(349): Webman\App::Webman\{closure}()
#2 G:\project\php\demo\webman-api\app\middleware\AccessControlTest.php(13): Webman\App::Webman\{closure}()
#3 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\App.php(341): app\middleware\AccessControlTest->process()
#4 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\App.php(560): Webman\App::Webman\{closure}()
#5 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\App.php(148): Webman\App::findRoute()
#6 G:\project\php\demo\webman-api\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage()
#7 G:\project\php\demo\webman-api\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead()
#8 G:\project\php\demo\webman-api\vendor\workerman\workerman\Worker.php(1488): Workerman\Events\Select->loop()
#9 G:\project\php\demo\webman-api\vendor\workerman\workerman\Worker.php(1405): Workerman\Worker::forkWorkersForWindows()
#10 G:\project\php\demo\webman-api\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#11 G:\project\php\demo\webman-api\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#12 G:\project\php\demo\webman-api\start.php(4): support\App::run()
#13 {main}
#### 操作系统及workerman/webman等框架组件具体版本
window10
header头,添加 accept: json
return response("测试", 405);这样是可以的,但是不理解为什么原生的会捕获不到异常
关掉debug就正常了,感觉像是官方的debug检查比较严格没有等到,过程当中有什么语法错误或者警告之类的直接500了
用它 https://www.workerman.net/plugin/16
已下载,只是不理解之前这么调用是可以的,为什么会出现这种情况,用过你很多的东西了 大佬
没搞懂你这句话什么所以?有个兜底500捕捉
关掉debug就没事了
是之前有同事使用这种语法,在本地报了500 所以就测试一下看看是什么原因
和是否关闭debug没关系,开启debug只是打印日志会详细点