Class MsalServiceException
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
stringThe protocol error code returned by the service or generated by client. This is the code you can rely on for exception handling.
errorMessage
stringThe 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
stringThe protocol 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.
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
stringThe protocol 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.
statusCode
intStatus 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
stringThe protocol 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.
statusCode
intHTTP status code of the response received from the service.
innerException
ExceptionThe 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
stringThe protocol 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.
statusCode
intThe status code of the request.
claims
stringThe claims challenge returned back from the service.
innerException
ExceptionThe 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:
- If your application is a IPublicClientApplication, you should just call AcquireTokenInteractive(IEnumerable<string>) and add the WithClaims(string) modifier.
- If your application is a IConfidentialClientApplication, (therefore doing the On-Behalf-Of flow), you should throw an HTTP unauthorize exception with a message containing the claims
[JsonInclude]
public string Claims { get; }
Property Value
Headers
Contains the HTTP headers from the server response that indicated an error.
public HttpResponseHeaders Headers { get; set; }
Property Value
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
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
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()