Sitelet https://github.com/npgsql/npgsql/pull/5982
Skip to content

Use exception convenience methods - #5982

Merged
roji merged 5 commits into
npgsql:mainfrom
bbowyersmyth:users/bruceb/exceptionConvenienceMethods
Dec 28, 2024
Merged

roji merged 5 commits into
npgsql:mainfrom
bbowyersmyth:users/bruceb/exceptionConvenienceMethods

Conversation

@bbowyersmyth

Copy link
Copy Markdown
Contributor

Use the built-in .net exception convenience methods where they make sense. Contributes to #2237
Converted most of the Parameter exceptions to convenience methods or the helper class.

Some observable changes:
NpgsqlRawCopyStream.ValidateArguments can throw ArgumentOutOfRangeException.
PgWriter.Write can throw ArgumentOutOfRangeException.
NpgsqlConnectionStringBuilder.HostRecheckSeconds now throws ArgumentOutOfRangeException.
ObjectDisposedException will use the type's FullName instead of a mix of class name and full name.
ArgumentException.ThrowIfNullOrEmpty/ThrowIfNullOrWhiteSpace will throw a ArgumentNullException if the value is null or just the ArgumentException base class if the value is empty.
Some exception messages are now just using the defaults. Left anything that looked meaningful or provided extra context.

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bbowyersmyth, LGTM

@roji
roji merged commit 010dc51 into npgsql:main Dec 28, 2024
@bbowyersmyth
bbowyersmyth deleted the users/bruceb/exceptionConvenienceMethods branch December 28, 2024 20:21
dvas-hash pushed a commit to dvas-hash/npgsql that referenced this pull request Jan 17, 2025
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.

2 participants