From bc82ebe3f18fe16f2430dac5004976d416cfa1cd Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Tue, 11 Jun 2024 12:42:06 -0400 Subject: [PATCH] GH-3530: Ensure all DbDataReader.TryGet extention methods catch all types of exceptions. --- .../AdoNet/DbRecordSetExtensions.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/NHibernate/AdoNet/DbRecordSetExtensions.cs b/src/NHibernate/AdoNet/DbRecordSetExtensions.cs index 444a1ecec1..5200b73a42 100644 --- a/src/NHibernate/AdoNet/DbRecordSetExtensions.cs +++ b/src/NHibernate/AdoNet/DbRecordSetExtensions.cs @@ -12,7 +12,7 @@ public static bool TryGetBoolean(this DbDataReader rs, int ordinal, out bool val value = rs.GetBoolean(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -26,7 +26,7 @@ public static bool TryGetByte(this DbDataReader rs, int ordinal, out byte value) value = rs.GetByte(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -40,7 +40,7 @@ public static bool TryGetChar(this DbDataReader rs, int ordinal, out char value) value = rs.GetChar(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -54,7 +54,7 @@ public static bool TryGetDecimal(this DbDataReader rs, int ordinal, out decimal value = rs.GetDecimal(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -68,7 +68,7 @@ public static bool TryGetDouble(this DbDataReader rs, int ordinal, out double va value = rs.GetDouble(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -82,7 +82,7 @@ public static bool TryGetDateTime(this DbDataReader rs, int ordinal, out DateTim value = rs.GetDateTime(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -95,7 +95,7 @@ public static bool TryGetFloat(this DbDataReader rs, int ordinal, out float valu value = rs.GetFloat(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -108,7 +108,7 @@ public static bool TryGetGuid(this DbDataReader rs, int ordinal, out Guid value) value = rs.GetGuid(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -136,7 +136,7 @@ public static bool TryGetInt16(this DbDataReader rs, int ordinal, out short valu value = rs.GetInt16(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -149,7 +149,7 @@ public static bool TryGetInt32(this DbDataReader rs, int ordinal, out int value) value = rs.GetInt32(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -177,7 +177,7 @@ public static bool TryGetInt64(this DbDataReader rs, int ordinal, out long value value = rs.GetInt64(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false; @@ -219,7 +219,7 @@ public static bool TryGetString(this DbDataReader rs, int ordinal, out string va value = rs.GetString(ordinal); return true; } - catch (InvalidCastException) + catch (Exception) { value = default; return false;