Skip to content

Use ThrowHelper for inline exception throws in NpgsqlConnection#6589

Open
LindqvistMartin wants to merge 1 commit into
npgsql:mainfrom
LindqvistMartin:fix/2237-throwhelper-part-2
Open

Use ThrowHelper for inline exception throws in NpgsqlConnection#6589
LindqvistMartin wants to merge 1 commit into
npgsql:mainfrom
LindqvistMartin:fix/2237-throwhelper-part-2

Conversation

@LindqvistMartin
Copy link
Copy Markdown

Part 2 of #2237. Picking up after vonzshik's #4872.

Replaced 7 inline throw new ... calls in NpgsqlConnection.cs with the existing ThrowHelper helpers. Same exception types and messages, pure mechanical change.

Skipped two:

  • The switch in Close: [DoesNotReturn] doesn't satisfy CS0163, so swapping needs an unreachable break; after the call. Felt noisier than just leaving the throw.
  • GetSchema uses the ArgumentOutOfRangeException(paramName, actualValue, message) ctor, and there's no matching ThrowHelper for that overload today.

Easy to widen to other files (NpgsqlCommand etc.) or add the missing helper for that ctor in a follow-up, if useful.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant