Class MsalException
Base exception type thrown when an error occurs during token acquisition. For more details, see https://aka.ms/msal-net-exceptions
public class MsalException : Exception, ISerializable
- Inheritance
-
MsalException
- Implements
- Derived
- Inherited Members
Remarks
Avoid throwing this exception. Instead throw the more specialized MsalClientException or MsalServiceException
Constructors
MsalException()
Initializes a new instance of the exception class.
public MsalException()
MsalException(string)
Initializes a new instance of the exception class with a specified error code.
public MsalException(string errorCode)
Parameters
errorCode
stringThe error code returned by the service or generated by the client. This is the code you can rely on for exception handling.
MsalException(string, string)
Initializes a new instance of the exception class with a specified error code and error message.
public MsalException(string errorCode, string errorMessage)
Parameters
errorCode
stringThe error code returned by the service or generated by the client. This is the code you can rely on for exception handling.
errorMessage
stringThe error message that explains the reason for the exception.
MsalException(string, string, Exception)
Initializes a new instance of the exception class with a specified error code and a reference to the inner exception that is the cause of this exception.
public MsalException(string errorCode, string errorMessage, Exception innerException)
Parameters
errorCode
stringThe error code returned by the service or generated by the client. This is the code you can rely on for exception handling.
errorMessage
stringThe error message that explains the reason for the exception.
innerException
ExceptionThe exception that is the cause of the current exception, or a null reference if no inner exception is specified.
Fields
BrokerErrorCode
An AdditionalExceptionData property key, available when using desktop brokers.
public const string BrokerErrorCode = "BrokerErrorCode"
Field Value
BrokerErrorContext
An AdditionalExceptionData property key, available when using desktop brokers.
public const string BrokerErrorContext = "BrokerErrorContext"
Field Value
BrokerErrorStatus
An AdditionalExceptionData property key, available when using desktop brokers.
public const string BrokerErrorStatus = "BrokerErrorStatus"
Field Value
BrokerErrorTag
An AdditionalExceptionData property key, available when using desktop brokers.
public const string BrokerErrorTag = "BrokerErrorTag"
Field Value
BrokerTelemetry
An AdditionalExceptionData property key, available when using desktop brokers.
public const string BrokerTelemetry = "BrokerTelemetry"
Field Value
ManagedIdentitySource
An AdditionalExceptionData property key, available when using managed identity.
public const string ManagedIdentitySource = "ManagedIdentitySource"
Field Value
Properties
AdditionalExceptionData
A property bag with extra details for this exception.
public IReadOnlyDictionary<string, string> AdditionalExceptionData { get; set; }
Property Value
CorrelationId
An ID that can used to piece up a single authentication flow.
public string CorrelationId { get; set; }
Property Value
ErrorCode
Gets the protocol error code returned by the service or generated by the client. This is the code you can rely on for exception handling. Values for this code are typically provided in constant strings in the derived exceptions types with explanations of mitigation.
public string ErrorCode { get; }
Property Value
IsRetryable
Indicates if the previous operation that resulted in this exception should be retried.
public bool IsRetryable { get; set; }
Property Value
Methods
FromJsonString(string)
Allows re-hydration of the MsalException (or one of its derived types) from JSON generated by ToJsonString().
public static MsalException FromJsonString(string json)
Parameters
json
string
Returns
ToJsonString()
Allows serialization of most values of the exception into JSON.
public string ToJsonString()
Returns
ToString()
Creates and returns a string representation of the current exception.
public override string ToString()
Returns
- string
A string representation of the current exception.