Skip to content

Enhance error logging in ApiRequestHelper to include received content on parsing failure #4895

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

Merged
merged 1 commit into from
May 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/Utilities/REST/ApiRequestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public T Get<T>(string url, bool camlCasePolicy = true, bool propertyNameCaseIns
}
catch (Exception e)
{
LogError($"Failed to parse response from server. Error message: '{e.Message}'. Model type to parse it to: '{typeof(T)}'.");
LogError($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{stringContent.Replace("{", "{{").Replace("}", "}}")}'. Model type to parse it to: '{typeof(T)}'.");
Copy link
Preview

Copilot AI May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the transformation logic for 'stringContent' into a dedicated helper function to improve clarity and maintainability of the logging statement.

Suggested change
LogError($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{stringContent.Replace("{", "{{").Replace("}", "}}")}'. Model type to parse it to: '{typeof(T)}'.");
LogError($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{EscapeCurlyBraces(stringContent)}'. Model type to parse it to: '{typeof(T)}'.");

Copilot uses AI. Check for mistakes.

//Cmdlet.LogWarning($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{stringContent}'. Model type to parse it to: '{typeof(T)}'.");
return default;
}
Expand Down
Loading