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