diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/AudienceValidationError.cs b/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/AudienceValidationError.cs index 4b19a5ecb2..23afb64089 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/AudienceValidationError.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/AudienceValidationError.cs @@ -39,11 +39,7 @@ public AudienceValidationError( /// An instance of an Exception. internal override Exception GetException() { - if (ExceptionType == typeof(SecurityTokenArgumentNullException)) - { - return new SecurityTokenArgumentNullException(MessageDetail.Message); - } - else if (ExceptionType == typeof(SecurityTokenInvalidAudienceException)) + if (ExceptionType == typeof(SecurityTokenInvalidAudienceException)) return new SecurityTokenInvalidAudienceException(MessageDetail.Message) { InvalidAudience = Utility.SerializeAsSingleCommaDelimitedString(_tokenAudiences) }; return base.GetException(ExceptionType, null); diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/ValidationError.cs b/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/ValidationError.cs index 4512e1a17c..d333f544f4 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/ValidationError.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/Results/Details/ValidationError.cs @@ -71,7 +71,9 @@ internal Exception GetException(Type exceptionType, Exception innerException) if (innerException == null && InnerValidationError == null) { - if (exceptionType == typeof(SecurityTokenInvalidAudienceException)) + if (exceptionType == typeof(SecurityTokenArgumentNullException)) + return new SecurityTokenArgumentNullException(MessageDetail.Message); + else if (exceptionType == typeof(SecurityTokenInvalidAudienceException)) exception = new SecurityTokenInvalidAudienceException(MessageDetail.Message); else if (exceptionType == typeof(SecurityTokenInvalidIssuerException)) exception = new SecurityTokenInvalidIssuerException(MessageDetail.Message); @@ -120,7 +122,9 @@ internal Exception GetException(Type exceptionType, Exception innerException) { Exception actualException = innerException ?? InnerValidationError.GetException(); - if (exceptionType == typeof(SecurityTokenInvalidAudienceException)) + if (exceptionType == typeof(SecurityTokenArgumentNullException)) + return new SecurityTokenArgumentNullException(MessageDetail.Message, innerException); + else if (exceptionType == typeof(SecurityTokenInvalidAudienceException)) exception = new SecurityTokenInvalidAudienceException(MessageDetail.Message, actualException); else if (exceptionType == typeof(SecurityTokenInvalidIssuerException)) exception = new SecurityTokenInvalidIssuerException(MessageDetail.Message, actualException);