Skip to content

Use ThrowHelper in JsonElement.GetByte/GetSByte/GetInt16/GetUInt16#126559

Open
prozolic wants to merge 2 commits intodotnet:mainfrom
prozolic:jsonelementget
Open

Use ThrowHelper in JsonElement.GetByte/GetSByte/GetInt16/GetUInt16#126559
prozolic wants to merge 2 commits intodotnet:mainfrom
prozolic:jsonelementget

Conversation

@prozolic
Copy link
Copy Markdown
Contributor

@prozolic prozolic commented Apr 5, 2026

This PR replace inline throw new FormatException() statements in JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with ThrowHelper.ThrowFormatException calls, consistent with the pattern established in #61746.

Replace inline `throw new FormatException()` statements in
JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with
ThrowHelper.ThrowFormatException calls, consistent with the pattern
established in dotnet#61746.
Copilot AI review requested due to automatic review settings April 5, 2026 11:25
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 5, 2026
@prozolic prozolic marked this pull request as ready for review April 5, 2026 11:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with the existing System.Text.Json throw-helper pattern by replacing inline throw new FormatException() statements with ThrowHelper.ThrowFormatException() calls, consistent with prior refactors (e.g., #61746).

Changes:

  • Refactors GetSByte() to throw via ThrowHelper.ThrowFormatException() when TryGetSByte() fails.
  • Refactors GetByte(), GetInt16(), and GetUInt16() similarly to centralize FormatException throwing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Text.Json community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants