在php异常中使用其他数据

 锋丽恋歌521 发布于 2023-01-20 16:19

我有执行python cgi的PHP代码,我想传递python跟踪(从cgi返回)作为额外的数据到php异常我该怎么做呢?我怎样才能从中获取该值catch(Exception e) {(它应该检查是否有额外的值exesit ).

我有这样的代码:

$response = json_decode(curl_exec($ch));
if (isset($response->error)) {
    // how to send $response->trace with exception.
    throw new Exception($response->error);
}
return $response->result;

我使用json-rpc库,应该将该数据返回给用户:

} catch (Exception $e) {
    //catch all exeption from user code
    $msg = $e->getMessage();
    echo response(null, $id, array("code"=>200, "message"=>$msg));
}

我是否需要编写新类型的异常,或者我可以正常Exception吗?我想发送所有扔进去的东西"data" =>

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有