Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding exception help message #4454

Merged
merged 13 commits into from
Jan 17, 2024
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,8 @@ 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));
var aadError = JsonHelper.GetExistingOrEmptyString(JsonHelper.ParseIntoJsonObject(msalServiceException.ResponseBody), OAuth2ResponseBaseClaim.ErrorDescription).Split(':').FirstOrDefault();
gladjohn marked this conversation as resolved.
Show resolved Hide resolved
trwalke marked this conversation as resolved.
Show resolved Hide resolved
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "AAD Error Code {0}", aadError));
trwalke marked this conversation as resolved.
Show resolved Hide resolved
}

if (ex.InnerException != null)
Expand All @@ -119,6 +124,8 @@ 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");
trwalke marked this conversation as resolved.
Show resolved Hide resolved

if (ex.StackTrace != null)
{
sb.Append(Environment.NewLine + ex.StackTrace);
trwalke marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading