异常处理
更新时间:2021-02-08
MCA 异常提示有如下三种方式:
异常方法 | 说明 |
---|---|
BceBaseException | 异常总集 |
BceClientException | 客户端异常 |
BceServerException | 服务器异常 |
InvalidArgumentException | 系统自带异常,参数错误 |
您可以使用try-catch获取某个事件所产生的异常:
Plain Text
1try {
2 $client->queryResult($source);
3 }catch (\BaiduBce\Exception\BceBaseException $e) {
4 print $e->getMessage();
5 if (stcmp(gettype($e), "BceClientException") == 0) {
6 print "Catch a client exception";
7 }
8 if (stcmp(gettype($e), "BceServerException") == 0) {
9 print "Catch a server exception";
10 }
11 }