Zum Inhalt springen

Rethrow loses the stack trace (CA2200)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.exception.rethrow-loses-stack · Severity warning · Category exception

Microsoft analyzer CA2200. Flags throw ex; inside a catch. It restarts the stack trace at the rethrow, hiding where the failure happened; throw; keeps it.

catch (IOException ex)
{
_logger.LogError(ex, "Upload failed");
throw ex;
}
catch (IOException ex)
{
_logger.LogError(ex, "Upload failed");
throw;
}