Skip to content

Commit

Permalink
Merge pull request robinrodricks#837 from jnyrup/ArgumentExceptions
Browse files Browse the repository at this point in the history
Some ArgumentExceptions take `paramName` as the first parameter
  • Loading branch information
robinrodricks authored Feb 13, 2022
2 parents 14e882b + c9b4ebe commit b5d0ce3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions FluentFTP/Client/FtpClient_Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@ public FtpClient() {
/// Creates a new instance of an FTP Client, with the given host.
/// </summary>
public FtpClient(string host) {
Host = host ?? throw new ArgumentNullException("Host must be provided");
Host = host ?? throw new ArgumentNullException(nameof(host), "Host must be provided");
m_listParser = new FtpListParser(this);
}

/// <summary>
/// Creates a new instance of an FTP Client, with the given host and credentials.
/// </summary>
public FtpClient(string host, NetworkCredential credentials) {
Host = host ?? throw new ArgumentNullException("Host must be provided");
Credentials = credentials ?? throw new ArgumentNullException("Credentials must be provided");
Host = host ?? throw new ArgumentNullException(nameof(host), "Host must be provided");
Credentials = credentials ?? throw new ArgumentNullException(nameof(credentials), "Credentials must be provided");
m_listParser = new FtpListParser(this);
}

/// <summary>
/// Creates a new instance of an FTP Client, with the given host, port and credentials.
/// </summary>
public FtpClient(string host, int port, NetworkCredential credentials) {
Host = host ?? throw new ArgumentNullException("Host must be provided");
Host = host ?? throw new ArgumentNullException(nameof(host), "Host must be provided");
Port = port;
Credentials = credentials ?? throw new ArgumentNullException("Credentials must be provided");
Credentials = credentials ?? throw new ArgumentNullException(nameof(credentials), "Credentials must be provided");
m_listParser = new FtpListParser(this);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ public FtpClient(Uri host, int port, string user, string pass, string account) {
/// <param name="host"></param>
private static string ValidateHost(Uri host) {
if (host == null) {
throw new ArgumentNullException("Host is required");
throw new ArgumentNullException(nameof(host), "Host is required");
}
#if !CORE
if (host.Scheme != Uri.UriSchemeFtp) {
Expand Down
8 changes: 4 additions & 4 deletions FluentFTP/Client/FtpClient_FXPFileTransfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public FtpStatus TransferFile(string sourcePath, FtpClient remoteClient, string

private void VerifyTransferFileParams(string sourcePath, FtpClient remoteClient, string remotePath, FtpRemoteExists existsMode) {
if (remoteClient is null) {
throw new ArgumentNullException("Destination FXP FtpClient cannot be null!", "remoteClient");
throw new ArgumentNullException(nameof(remoteClient), "Destination FXP FtpClient cannot be null!");
}

if (sourcePath.IsBlank()) {
throw new ArgumentNullException("FtpListItem must be specified!", "sourceFtpFileItem");
throw new ArgumentNullException(nameof(sourcePath), "FtpListItem must be specified!");
}

if (remotePath.IsBlank()) {
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
throw new ArgumentException("Required parameter is null or blank.", nameof(remotePath));
}

if (!remoteClient.IsConnected) {
Expand All @@ -101,7 +101,7 @@ private void VerifyTransferFileParams(string sourcePath, FtpClient remoteClient,
}

if (existsMode == FtpRemoteExists.AddToEnd || existsMode == FtpRemoteExists.AddToEndNoCheck) {
throw new ArgumentException("FXP file transfer does not currently support AddToEnd or AddToEndNoCheck modes. Use another value for existsMode.", "existsMode");
throw new ArgumentException("FXP file transfer does not currently support AddToEnd or AddToEndNoCheck modes. Use another value for existsMode.", nameof(existsMode));
}
}

Expand Down
12 changes: 6 additions & 6 deletions FluentFTP/Client/FtpClient_FXPVerification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ private bool VerifyFXPTransfer(string sourcePath, FtpClient fxpDestinationClient

// verify args
if (sourcePath.IsBlank()) {
throw new ArgumentException("Required parameter is null or blank.", "localPath");
throw new ArgumentException("Required parameter is null or blank.", nameof(sourcePath));
}

if (remotePath.IsBlank()) {
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
throw new ArgumentException("Required parameter is null or blank.", nameof(remotePath));
}

if (fxpDestinationClient is null) {
throw new ArgumentNullException("Destination FXP FtpClient cannot be null!", "fxpDestinationClient");
throw new ArgumentNullException(nameof(fxpDestinationClient), "Destination FXP FtpClient cannot be null!");
}

// check if any algorithm is supported by both servers
Expand Down Expand Up @@ -61,15 +61,15 @@ private bool VerifyFXPTransfer(string sourcePath, FtpClient fxpDestinationClient

// verify args
if (sourcePath.IsBlank()) {
throw new ArgumentException("Required parameter is null or blank.", "localPath");
throw new ArgumentException("Required parameter is null or blank.", nameof(sourcePath));
}

if (remotePath.IsBlank()) {
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
throw new ArgumentException("Required parameter is null or blank.", nameof(remotePath));
}

if (fxpDestinationClient is null) {
throw new ArgumentNullException("Destination FXP FtpClient cannot be null!", "fxpDestinationClient");
throw new ArgumentNullException(nameof(fxpDestinationClient), "Destination FXP FtpClient cannot be null!");
}

// check if any algorithm is supported by both servers
Expand Down
4 changes: 2 additions & 2 deletions FluentFTP/Client/FtpClient_Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ public double TimeZone {
get => m_serverTimeZone;
set {
if (value < -14 || value > 14) {
throw new ArgumentOutOfRangeException("TimeZone must be within -14 to +14 to represent UTC-14 to UTC+14");
throw new ArgumentOutOfRangeException(nameof(value), "TimeZone must be within -14 to +14 to represent UTC-14 to UTC+14");
}
m_serverTimeZone = value;

Expand Down Expand Up @@ -857,7 +857,7 @@ public double LocalTimeZone {
get => m_localTimeZone;
set {
if (value < -14 || value > 14) {
throw new ArgumentOutOfRangeException("LocalTimeZone must be within -14 to +14 to represent UTC-14 to UTC+14");
throw new ArgumentOutOfRangeException(nameof(value), "LocalTimeZone must be within -14 to +14 to represent UTC-14 to UTC+14");
}
m_localTimeZone = value;

Expand Down

0 comments on commit b5d0ce3

Please sign in to comment.