开发者

soapClient use SoapFault or Exception or both to catch Error?

Which of the following is better to catch an error when calling a web service us开发者_如何转开发ing SoapClent?

try {
  $response = $client->SomeSoapRequest();
}
  catch(SoapFault $e){
}

Or:

try {
  $response = $client->SomeSoapRequest();
}
  catch(SoapFault $e){
}
  catch(Exception $e){
}

Also, I want to catch a socket timeout; will this be a SoapFault or an Exception?

Thanks!


Just catch Exception; this will also catch SoapFault. If you need to know the difference, you can check the type of the object received. Exception will also catch other non-soapfault exceptions, which you should be doing anyway. So, the answer is: the second one.


you can find some answers at this similar question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜