如何捕获错误,如无法打开流和连接超时
16lz
2021-01-22
I got a code that interacts with a soap client that I enclose with a try catch statement. But it seems that the try catch statement could not catch the error as the script would fail. I would like the code to continue the execution even after the error.
我得到了一个与soap客户端交互的代码,我将其与try catch语句一起包含在内。但似乎try catch语句无法捕获错误,因为脚本会失败。我希望代码在错误发生后继续执行。
The error is [error] [php]SoapClient::SoapClient(): failed to open stream: Connection timed out
错误是[错误] [php] SoapClient :: SoapClient():无法打开流:连接超时
How to better handle the error without stopping the execution of the code?
如何更好地处理错误而不停止执行代码?
Below is the code.
以下是代码。
try{
$client = new SoapClient($url, $config);
$result = $client->RemoteMethod(
array( "param1" =>$data1
"param2" => $data2
"param3" => $data3
)
);
$response = objectToArray($result);
}catch(Exception $e){
}
2 个解决方案
#1
1
What is the current namespace? Try changing the catch
to:
什么是当前的命名空间?尝试将捕获更改为:
}catch(\Exception $e){
(Note the backslash.)
(注意反斜杠。)
更多相关文章
- fgetcsv()错误地将双引号添加到第一行的第一个元素
- CakePHP错误:在Acl中找不到类'String'
- 错误1452:无法添加或更新子行:外键约束失败
- 韩顺平_php从入门到精通_视频教程_学习笔记_源代码图解_PPT文档
- 【MySQL 技巧分享】 mysql -e 加 v 简化代码
- Oracle相当于MySQL代码“插入虚拟”以返回错误消息
- 登录使用PHP并´t显示任何html代码
- MySQL添加外键错误1215
- 在SQL中声明@变量返回错误