Table of Contents

Class MsalServiceException

Namespace
Microsoft.Identity.Client
Assembly
Microsoft.Identity.Client.dll

Exception type thrown when service returns an error response or other networking errors occur. For more details, see https://aka.ms/msal-net-exceptions

public class MsalServiceException : MsalException, ISerializable
Inheritance
MsalServiceException
Implements
Derived
Inherited Members

Constructors

MsalServiceException(string, string)

Initializes a new instance of the exception class with a specified error code, error message and a reference to the inner exception that is the cause of this exception.

public MsalServiceException(string errorCode, string errorMessage)

Parameters

errorCode string

The protocol error code returned by the service or generated by client. This is the code you can rely on for exception handling.

errorMessage string

The error message that explains the reason for the exception.

MsalServiceException(string, string, Exception)

Initializes a new instance of the exception class with a specified error code, error message and a reference to the inner exception that is the cause of this exception.

public MsalServiceException(string errorCode, string errorMessage, Exception innerException)

Parameters

errorCode string

The protocol error code returned by the service or generated by the client. This is the code you can rely on for exception handling.

errorMessage string

The error message that explains the reason for the exception.

innerException Exception

The exception that is the cause of the current exception, or a null reference if no inner exception is specified.

MsalServiceException(string, string, int)

Initializes a new instance of the exception class with a specified error code, error message and a reference to the inner exception that is the cause of this exception.

public MsalServiceException(string errorCode, string errorMessage, int statusCode)

Parameters

errorCode string

The protocol error code returned by the service or generated by the client. This is the code you can rely on for exception handling.

errorMessage string

The error message that explains the reason for the exception.

statusCode int

Status code of the response received from the service.

MsalServiceException(string, string, int, Exception)

Initializes a new instance of the exception class with a specified error code, error message and a reference to the inner exception that is the cause of this exception.

public MsalServiceException(string errorCode, string errorMessage, int statusCode, Exception innerException)

Parameters

errorCode string

The protocol error code returned by the service or generated by the client. This is the code you can rely on for exception handling.

errorMessage string

The error message that explains the reason for the exception.

statusCode int

HTTP status code of the response received from the service.

innerException Exception

The exception that is the cause of the current exception, or a null reference if no inner exception is specified.

MsalServiceException(string, string, int, string, Exception)

Initializes a new instance of the exception class with a specified error code, error message and a reference to the inner exception that is the cause of this exception.

public MsalServiceException(string errorCode, string errorMessage, int statusCode, string claims, Exception innerException)

Parameters

errorCode string

The protocol error code returned by the service or generated by the client. This is the code you can rely on for exception handling.

errorMessage string

The error message that explains the reason for the exception.

statusCode int

The status code of the request.

claims string

The claims challenge returned back from the service.

innerException Exception

The exception that is the cause of the current exception, or a null reference if no inner exception is specified.

Properties

Claims

Additional claims requested by the service. When this property is not null or empty, this means that the service requires the user to provide additional claims, such as doing two factor authentication. The are two cases:

For more details see https://aka.ms/msal-net-claim-challenge
[JsonInclude]
public string Claims { get; }

Property Value

string

Headers

Contains the HTTP headers from the server response that indicated an error.

public HttpResponseHeaders Headers { get; set; }

Property Value

HttpResponseHeaders

Remarks

When the server returns a 429 Too Many Requests error, a Retry-After should be set. It is important to read and respect the time specified in the Retry-After header to avoid a retry storm.

ResponseBody

Raw response body received from the server.

public string ResponseBody { get; set; }

Property Value

string

StatusCode

Gets the status code returned from HTTP layer. This status code is either the HttpStatusCode in the inner HttpRequestException response or the NavigateError Event Status Code in a browser based flow (see NavigateError Event Status Codes). You can use this code for purposes such as implementing retry logic or error investigation.

public int StatusCode { get; }

Property Value

int

Methods

ToString()

Creates and returns a string representation of the current exception.

public override string ToString()

Returns

string

A string representation of the current exception.

UpdateIsRetryable()

As per discussion with Evo, AAD

protected virtual void UpdateIsRetryable()