== Why is this an issue?

Creating a new ``++Exception++`` without actually throwing it is useless and is probably due to a mistake.

=== Noncompliant code example

[source,vbnet]
----
If x < 0 Then
    Dim ex = New ArgumentException("x must be nonnegative")
End If
----

=== Compliant solution

[source,vbnet]
----
If x < 0 Then
    Throw New ArgumentException("x must be nonnegative")
End If
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../message.adoc[]

include::../highlighting.adoc[]

'''
== Comments And Links
(visible only on this page)

=== on 5 Sep 2017, 14:35:39 Duncan Pocklington wrote:
The C# implementation of this rule catches one invalid case:


{{new Exception(...)

}}


However, this isn't valid syntax in VB.Net (i.e. it will be reported as a syntax error in the IDE).


For this rule to be useful in VB it would need to be more complex i.e. check for exceptions that are created and assigned to a variable/field/property that are not then returned, passed to another method, or returned, or thrown.


\[~jeanchristophe.collet] should we just park this issue for VB for now?

=== on 5 Sep 2017, 15:02:19 Jean-Christophe Collet wrote:
Agreed, work on this should be postponed for now.

=== on 5 Oct 2018, 09:08:08 Loïc Joly wrote:
The current implementation for C# is just checking that the exception object is used somehow. But in VB.NET, it's not possible to create an object without using it, so the rule would never be triggered.


If the C# implementation tracked the value to see if it was really thrown (requiring inter-procedural symbolic execution), then it would make sense to reactivate this rule for VB.NET too.

endif::env-github,rspecator-view[]
