dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
739 stars 1.57k forks source link

Improve `System.FormatException` docs #10363

Open Rabadash8820 opened 2 months ago

Rabadash8820 commented 2 months ago

Type of issue

Missing information

Description

According to the current FormatException docs:

The exception that is thrown when the format of an argument is invalid, or when a composite format string is not well formed.

However, as described in this StackOverflow post:

FormatException is not necessarily thrown when a formal argument of a method is invalid. It can also happen if the method is consuming an external resource and the format of the data from the external resource is inappropriate.

For example, BinaryReader.Read7BitEncodedInt will throw FormatException if what it's going to read from a stream is not a valid 7-bit encoded integer. It doesn't take any arguments at all. ArgumentException, on the other hand, should only get thrown when an argument passed as a formal parameter to a method is invalid.

The docs should be updated to clarify this. I'd be willing to try a PR if someone wants to point me to the right files.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.formatexception?view=net-8.0&redirectedfrom=MSDN

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/FormatException.xml

Document Version Independent Id

691e8234-8211-094f-f6d7-b22ed063cfc5

Article author

@dotnet-bot

dotnet-issue-labeler[bot] commented 2 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 2 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-policy-service[bot] commented 1 week ago

Tagging subscribers to this area: @dotnet/area-system-runtime