Skip to content

Commit bc82ebe

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
GH-3530: Ensure all DbDataReader.TryGet extention methods catch all types of exceptions.
1 parent 3d8bc0e commit bc82ebe

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/NHibernate/AdoNet/DbRecordSetExtensions.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static bool TryGetBoolean(this DbDataReader rs, int ordinal, out bool val
1212
value = rs.GetBoolean(ordinal);
1313
return true;
1414
}
15-
catch (InvalidCastException)
15+
catch (Exception)
1616
{
1717
value = default;
1818
return false;
@@ -26,7 +26,7 @@ public static bool TryGetByte(this DbDataReader rs, int ordinal, out byte value)
2626
value = rs.GetByte(ordinal);
2727
return true;
2828
}
29-
catch (InvalidCastException)
29+
catch (Exception)
3030
{
3131
value = default;
3232
return false;
@@ -40,7 +40,7 @@ public static bool TryGetChar(this DbDataReader rs, int ordinal, out char value)
4040
value = rs.GetChar(ordinal);
4141
return true;
4242
}
43-
catch (InvalidCastException)
43+
catch (Exception)
4444
{
4545
value = default;
4646
return false;
@@ -54,7 +54,7 @@ public static bool TryGetDecimal(this DbDataReader rs, int ordinal, out decimal
5454
value = rs.GetDecimal(ordinal);
5555
return true;
5656
}
57-
catch (InvalidCastException)
57+
catch (Exception)
5858
{
5959
value = default;
6060
return false;
@@ -68,7 +68,7 @@ public static bool TryGetDouble(this DbDataReader rs, int ordinal, out double va
6868
value = rs.GetDouble(ordinal);
6969
return true;
7070
}
71-
catch (InvalidCastException)
71+
catch (Exception)
7272
{
7373
value = default;
7474
return false;
@@ -82,7 +82,7 @@ public static bool TryGetDateTime(this DbDataReader rs, int ordinal, out DateTim
8282
value = rs.GetDateTime(ordinal);
8383
return true;
8484
}
85-
catch (InvalidCastException)
85+
catch (Exception)
8686
{
8787
value = default;
8888
return false;
@@ -95,7 +95,7 @@ public static bool TryGetFloat(this DbDataReader rs, int ordinal, out float valu
9595
value = rs.GetFloat(ordinal);
9696
return true;
9797
}
98-
catch (InvalidCastException)
98+
catch (Exception)
9999
{
100100
value = default;
101101
return false;
@@ -108,7 +108,7 @@ public static bool TryGetGuid(this DbDataReader rs, int ordinal, out Guid value)
108108
value = rs.GetGuid(ordinal);
109109
return true;
110110
}
111-
catch (InvalidCastException)
111+
catch (Exception)
112112
{
113113
value = default;
114114
return false;
@@ -136,7 +136,7 @@ public static bool TryGetInt16(this DbDataReader rs, int ordinal, out short valu
136136
value = rs.GetInt16(ordinal);
137137
return true;
138138
}
139-
catch (InvalidCastException)
139+
catch (Exception)
140140
{
141141
value = default;
142142
return false;
@@ -149,7 +149,7 @@ public static bool TryGetInt32(this DbDataReader rs, int ordinal, out int value)
149149
value = rs.GetInt32(ordinal);
150150
return true;
151151
}
152-
catch (InvalidCastException)
152+
catch (Exception)
153153
{
154154
value = default;
155155
return false;
@@ -177,7 +177,7 @@ public static bool TryGetInt64(this DbDataReader rs, int ordinal, out long value
177177
value = rs.GetInt64(ordinal);
178178
return true;
179179
}
180-
catch (InvalidCastException)
180+
catch (Exception)
181181
{
182182
value = default;
183183
return false;
@@ -219,7 +219,7 @@ public static bool TryGetString(this DbDataReader rs, int ordinal, out string va
219219
value = rs.GetString(ordinal);
220220
return true;
221221
}
222-
catch (InvalidCastException)
222+
catch (Exception)
223223
{
224224
value = default;
225225
return false;

0 commit comments

Comments
 (0)