不过,这可能听起来像是一个科幻请求——有没有办法返回到从try {}
块内抛出异常的块的开头catch() {}
?
这是一个例子:
try
{
// make OAuth request
}
catch(OAuthException $e)
{
// if(){}
// If tells me that the Exception was thrown because the access token is expired
// I have alternative access token (that's always up to date, but there is a catch why I void using it)
// I set it as a new access token and want to repeat the try {} block
}
显然goto
可以做到,不过,我正在寻找是否有更复杂的方法。