Skip to content

Commit f7a7941

Browse files
ChenHuajunroji
authored andcommitted
fix some bugs when throwing ArgumentOutOfRangeException
Some fixups by roji Conflicts: src/Npgsql/NpgsqlCommand.cs
1 parent fc25a2d commit f7a7941

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

Npgsql/Npgsql/NpgsqlCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public override Int32 CommandTimeout
241241
{
242242
if (value < 0)
243243
{
244-
throw new ArgumentOutOfRangeException(resman.GetString("Exception_CommandTimeoutLessZero"));
244+
throw new ArgumentOutOfRangeException("value", resman.GetString("Exception_CommandTimeoutLessZero"));
245245
}
246246

247247
timeout = value;

Npgsql/Npgsql/NpgsqlConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ public override void ChangeDatabase(String dbName)
672672

673673
if (string.IsNullOrEmpty(dbName))
674674
{
675-
throw new ArgumentOutOfRangeException(String.Format(resman.GetString("Exception_InvalidDbName"), dbName), "dbName");
675+
throw new ArgumentOutOfRangeException("dbName", dbName, String.Format(resman.GetString("Exception_InvalidDbName")));
676676
}
677677

678678
String oldDatabaseName = Database;
@@ -1189,7 +1189,7 @@ public override DataTable GetSchema(string collectionName, string[] restrictions
11891189
case "ForeignKeys":
11901190
return NpgsqlSchema.GetForeignKeys(tempConn, restrictions);
11911191
default:
1192-
throw new ArgumentOutOfRangeException("collectionName", collectionName);
1192+
throw new ArgumentOutOfRangeException("collectionName", collectionName, "Invalid collection name");
11931193
}
11941194
}
11951195
}

Npgsql/Npgsql/NpgsqlParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public NpgsqlDbType NpgsqlDbType
381381
bound = false;
382382
if (value == NpgsqlDbType.Array)
383383
{
384-
throw new ArgumentOutOfRangeException(resman.GetString("Exception_ParameterTypeIsOnlyArray"));
384+
throw new ArgumentOutOfRangeException("value", resman.GetString("Exception_ParameterTypeIsOnlyArray"));
385385
}
386386
if (!NpgsqlTypesHelper.TryGetNativeTypeInfo(value, out type_info))
387387
{

Npgsql/NpgsqlTypes/DateDatatypes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,13 +2880,13 @@ public NpgsqlInterval Subtract(NpgsqlTimeStamp timestamp)
28802880
{
28812881
case TimeType.Infinity:
28822882
case TimeType.MinusInfinity:
2883-
throw new ArgumentOutOfRangeException("You cannot subtract infinity timestamps");
2883+
throw new ArgumentOutOfRangeException("this", "You cannot subtract infinity timestamps");
28842884
}
28852885
switch (timestamp._type)
28862886
{
28872887
case TimeType.Infinity:
28882888
case TimeType.MinusInfinity:
2889-
throw new ArgumentOutOfRangeException("You cannot subtract infinity timestamps");
2889+
throw new ArgumentOutOfRangeException("timestamp", "You cannot subtract infinity timestamps");
28902890
}
28912891
return new NpgsqlInterval(0, _date.DaysSinceEra - timestamp._date.DaysSinceEra, _time.Ticks - timestamp._time.Ticks);
28922892
}
@@ -3364,13 +3364,13 @@ public NpgsqlInterval Subtract(NpgsqlTimeStampTZ timestamp)
33643364
{
33653365
case TimeType.Infinity:
33663366
case TimeType.MinusInfinity:
3367-
throw new ArgumentOutOfRangeException("You cannot subtract infinity timestamps");
3367+
throw new ArgumentOutOfRangeException("this", "You cannot subtract infinity timestamps");
33683368
}
33693369
switch (timestamp._type)
33703370
{
33713371
case TimeType.Infinity:
33723372
case TimeType.MinusInfinity:
3373-
throw new ArgumentOutOfRangeException("You cannot subtract infinity timestamps");
3373+
throw new ArgumentOutOfRangeException("timestamp", "You cannot subtract infinity timestamps");
33743374
}
33753375
return new NpgsqlInterval(0, _date.DaysSinceEra - timestamp._date.DaysSinceEra, (_time - timestamp._time).Ticks);
33763376
}

0 commit comments

Comments
 (0)