Skip to content

Commit

Permalink
Adding exception help message (#4454)
Browse files Browse the repository at this point in the history
* Adding exception help

* Updating error message with error code

* Error code update

* revert

* clean up

* clean up

* Updating error code parsing

* Updating error codes

---------

Co-authored-by: trwalke <[email protected]>
  • Loading branch information
trwalke and trwalke authored Jan 17, 2024
1 parent 89a9cc7 commit 80b896d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.Identity.Client.Core;
using Microsoft.Identity.Client.OAuth2;
using Microsoft.Identity.Client.PlatformsCommon.Factories;
using Microsoft.Identity.Client.Utils;
using Microsoft.IdentityModel.Abstractions;

namespace Microsoft.Identity.Client.Internal.Logger
Expand Down Expand Up @@ -110,6 +113,10 @@ internal static string GetPiiScrubbedExceptionDetails(Exception ex)
{
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "HTTP StatusCode {0}", msalServiceException.StatusCode));
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "CorrelationId {0}", msalServiceException.CorrelationId));
if (msalServiceException.ErrorCodes != null && msalServiceException.ErrorCodes.Count() > 0)
{
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "Microsoft Entra ID Error Code AADSTS{0}", string.Join(" ", msalServiceException.ErrorCodes)));
}
}

if (ex.InnerException != null)
Expand All @@ -119,9 +126,11 @@ internal static string GetPiiScrubbedExceptionDetails(Exception ex)
sb.AppendLine("=== End of inner exception stack trace ===");
}

sb.AppendLine("To see full exception details, enable PII Logging. See https://aka.ms/msal-net-logging");

if (ex.StackTrace != null)
{
sb.Append(Environment.NewLine + ex.StackTrace);
sb.AppendLine(ex.StackTrace);
}
}

Expand Down

0 comments on commit 80b896d

Please sign in to comment.