dotnet / dotnet/docs

Exception with required property

Open
#22,046 4 comments 1 reaction 0 assignees View on GitHub
:construction: Hold for related PR dotnet-fundamentals/svc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

Moved issue to .NET
Old issue: [https://github.com/MicrosoftDocs/visualstudio-docs/issues/3228](https://github.com/MicrosoftDocs/visualstudio-docs/issues/3228), opened by @motz-art

For full discussion of issue, see **3228**.

Hi,

I would like to suggest an enhancement for case when Exception must have some properties initialized.

Documentation says that "Failure to provide the full set of constructors can make it difficult to correctly handle exceptions.". Is it fine to Suppress the warning in this case when next constructors provided: CustomException(RequiredData), CustomException(RequiredData, string), CustomException(RequiredData, string, Exception)?

So having CustomException(RequiredData, string, Exception) would still allow me to create custom exception and specify that it's caused by another exception.

If it's not fine to suppress, please explain why and what is the best practice?

Thank you

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 9abd4d8f-7c08-c6b6-f05c-f40c359fc550
* Version Independent ID: 19e424e2-3191-b900-de2d-40ff3eb41ca4
* Content: [CA1032: Implement standard exception constructors (code analysis) - .NET](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1032)
* Content Source: [docs/fundamentals/code-analysis/quality-rules/ca1032.md](https://github.com/dotnet/docs/blob/master/docs/fundamentals/code-analysis/quality-rules/ca1032.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @gewarren
* Microsoft Alias: **gewarren**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.