This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

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

PREVIEWING: rtrieu/product-analytics-ui-changes