Skip to content

Fix CA2200: Preserve stack trace when re-throwing exceptions in XmlRpcManager#764

Merged
poppastring merged 2 commits into
mainfrom
copilot/fix-ca2200-rethrowing-exception
Jan 19, 2026
Merged

Fix CA2200: Preserve stack trace when re-throwing exceptions in XmlRpcManager#764
poppastring merged 2 commits into
mainfrom
copilot/fix-ca2200-rethrowing-exception

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

The XmlRpcManager.Invoke method was using throw ex; which resets the exception stack trace, losing the original call stack information critical for debugging.

Changes

  • Changed throw ex; to throw; in the catch block at line 140 of XmlRpcManager.cs

This preserves the original stack trace as per CA2200:

catch (Exception ex)
{
    loggingDataService.AddEvent(new EventDataItem(EventCodes.Error, ex.Message, "XmlRpcManager.Invoke"));
    
    if (ex.InnerException != null)
    {
        throw ex.InnerException;
    }
-   throw ex;  // Resets stack trace
+   throw;     // Preserves stack trace
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix CA2200: Re-throwing caught exception changes stack information</issue_title>
<issue_description>The code in DasBlog.Managers (XmlRpcManager.cs) re-throws a caught exception, which changes stack information and can make debugging harder.

File:

  • DasBlog.Web.Repositories\XmlRpcManager.cs (line 140)

Consider using 'throw;' instead of 'throw ex;' to preserve the original stack trace.

Reference: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: poppastring <8739371+poppastring@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CA2200 by using throw statement to preserve stack trace Fix CA2200: Preserve stack trace when re-throwing exceptions in XmlRpcManager Jan 19, 2026
Copilot AI requested a review from poppastring January 19, 2026 00:46
@poppastring poppastring marked this pull request as ready for review January 19, 2026 01:35
@poppastring poppastring merged commit 6565d46 into main Jan 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix CA2200: Re-throwing caught exception changes stack information

2 participants