【发布时间】:2018-10-10 12:04:50
【问题描述】:
当您尝试从 Azure Active Directory 获取令牌时,如果在获取令牌期间发生错误,则会引发异常类型。
异常被称为 AdalException ms docs link here
我在寻找它的属性 ErrorCode ms docs link here
然而,他们称之为“错误代码”,它是一个字符串,具有可能的值,例如:
- “temporarily_unavailable”
- “user_interaction_required”
- 等等……
从偷看它说的程序集
// Parameters:
// errorCode:
// The error code returned by the service or generated by client. This is the code
// you can rely on for exception handling.
您能否指出我可以从中获取所有可能值的方向?还是它的价值只是信息性的、独特的或随机的?
我想做的是有一个不同的逻辑,所以假设它暂时不可用,是否重试?如果是其他事情,则采取相应的行动……
伪代码:
catch (AdalException ex)
{
if (ex.ErrorCode == "temporarily_unavailable")
{
retry = true;
retryCount++;
Thread.Sleep(3000);
}
else if (ex.ErrorCode == "foo")
// rest of the code omitted for brevity...
}
【问题讨论】:
标签: c# azure exception azure-active-directory adal