Skip to content

Commit cc60761

Browse files
General exception error not on invocation expr #77
1 parent a5c44c7 commit cc60761

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CheckedExceptions/CheckedExceptionsAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ private void AnalyzeExceptionThrowingNode(
12021202
}
12031203

12041204
// Check for general exceptions
1205-
if (IsGeneralException(exceptionType))
1205+
if (context.Node is not InvocationExpressionSyntax && IsGeneralException(exceptionType))
12061206
{
12071207
context.ReportDiagnostic(Diagnostic.Create(RuleGeneralThrow, node.GetLocation()));
12081208
}

Test/Cases/GeneralThrowFix.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Test.Cases;
2+
3+
//C.M(); // THROW004: Throwing 'Exception' is too general; use a more specific exception type instead
4+
5+
class C
6+
{
7+
[Throws(typeof(Exception))]
8+
public static void M() { }
9+
}

0 commit comments

Comments
 (0)