All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.vbnet.S3871.html Maven / Gradle / Ivy

There is a newer version: 10.5.0.109200
Show newest version

Why is this an issue?

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.

This rule will raise an issue if you directly inherit one of the following exception types in a non-public class:

How to fix it

Code examples

Noncompliant code example

Friend Class MyException    ' Noncompliant
    Inherits Exception
    ' ...
End Class

Compliant solution

Public Class MyException
    Inherits Exception
    ' ...
End Class

Resources

Documentation





© 2015 - 2025 Weber Informatics LLC | Privacy Policy