語言

MicrosoftIdentityAuthenticationException 建構函式

定義

多載

名稱 Description
MicrosoftIdentityAuthenticationException(String)

初始化類別的新實例 MicrosoftIdentityAuthenticationException 並指定錯誤訊息。

MicrosoftIdentityAuthenticationException(String, Exception)

初始化類別的新實例 MicrosoftIdentityAuthenticationException ,並附上指定的錯誤訊息及導致該異常的內部例外的參考。

MicrosoftIdentityAuthenticationException(String)

初始化類別的新實例 MicrosoftIdentityAuthenticationException 並指定錯誤訊息。

public MicrosoftIdentityAuthenticationException(string message);
new Microsoft.Identity.Web.MicrosoftIdentityAuthenticationException : string -> Microsoft.Identity.Web.MicrosoftIdentityAuthenticationException
Public Sub New (message As String)

參數

message
String

錯誤訊息解釋了例外原因。

範例

throw new MicrosoftIdentityAuthenticationException(
    "Authentication options must be configured either in default options or per-request using WithAuthenticationOptions().");

適用於

MicrosoftIdentityAuthenticationException(String, Exception)

初始化類別的新實例 MicrosoftIdentityAuthenticationException ,並附上指定的錯誤訊息及導致該異常的內部例外的參考。

public MicrosoftIdentityAuthenticationException(string message, Exception innerException);
new Microsoft.Identity.Web.MicrosoftIdentityAuthenticationException : string * Exception -> Microsoft.Identity.Web.MicrosoftIdentityAuthenticationException
Public Sub New (message As String, innerException As Exception)

參數

message
String

錯誤訊息解釋了例外原因。

innerException
Exception

該例外是當前例外的原因,或 null 若未指定內部例外。

範例

try
{
    var authHeader = await headerProvider.CreateAuthorizationHeaderAsync(scopes, options);
}
catch (Exception ex)
{
    throw new MicrosoftIdentityAuthenticationException("Failed to acquire authorization header.", ex);
}

備註

當你想保留導致認證失敗的原始例外時,例如底層令牌取得提供者的例外,請使用此建構子。

適用於