Exceptions should be made public

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

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