Exceptions should be made public

Metadata

ID: csharp-best-practices/exceptions-public

Language: C#

Severity: Warning

Category: Best Practices

Description

Exceptions should not be made internal and should be made public. Exceptions are designed to be reused across the codebase or in multiple codebases. By making an exception internal, it then cannot be reused across the different codebases.

Non-Compliant Code Examples

internal class MyCustomException: Exception {
    
}

Compliant Code Examples

public class MyCustomException: Exception {
    
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis