The point of having custom exception types is to convey more information than is available in standard types. But custom exception types must be
Public
for that to work.
If a method throws a non-public exception, the best you can do on the caller’s side is to Catch
the closest Public
base
of the class. However, you lose all the information that the new exception type carries.
Noncompliant Code Example
Friend Class MyException ' Noncompliant
Inherits Exception
' ...
End Class
Compliant Solution
Public Class MyException ' Noncompliant
Inherits Exception
' ...
End Class
Exceptions
This rule ignores Exception types that are not derived directly from System.Exception
, System.SystemException
, or
System.ApplicationException
.
See