Closing bracket uncovered in try-catch statement when exception is re-thrown in catch
See original GitHub issueThe closing bracket is showing up as uncovered when I re-throw an exception from a catch
statement. Is this expected behavior? The closing bracket is technically unreachable code, and it prevents me from reaching 100% coverage on the method when coverlet says it is uncovered by a test.
try
{
...
}
catch (Exception)
{
// handle exception (retry/log/etc.)
throw;
} // ** uncovered line **
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Closing bracket uncovered in try-catch statement when ...
The closing bracket is showing up as uncovered when I re-throw an exception from a catch statement. Is this expected behavior?
Read more >java - Does the catch in try-with-resources cover the code ...
So yes, the exception will be caught by your catch block. Share.
Read more >C++ Tutorial: Handling Exceptions - 2020
The catch keyword declares the exception handler. It follows immediately the closing brace of the try block. The format for catch is similar...
Read more >What is Exception Handling? - SearchSoftwareQuality
The try bracket is used to contain the code that encounters the exception, so the application does not crash. The catch block is...
Read more >Why are brackets required for try-catch?
To reiterate/summarize: the braces group together the statements controlled by the catch s, but do not group the catch s themselves. As such, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This only seems to be an issue when there is an
await
inside the catch block. Here is a repro:https://github.com/brpratt/CoverletAwaitThrowInsideCatch
From the generated code, it seems there is a branch while deciding how to re-throw the exception. In the linked example, maybe this is the offender?
Updated my coverlet.msbuild and it works! Thanks @MarcoRossignoli