问题描述
我正在使用一个正在编写的第三方库。我试图捕获第三方库可能抛出的异常,然后将其重新抛出。在保留跟踪的同时该如何做?
use ThirdParty;
use ThirdPartyException;
class MyLib {
protected $third_party;
public function __construct(ThirdParty $third_party)
{
$this->third_party = $third_party;
}
/**
* @throws MyLibException
*/
public function doSomething() {
try {
$var = $this->third_party->method();
} catch (ThirdPartyException $e) {
throw new MyLibException('There was an error doing something');
}
// Continue doing something...
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)