Skip to content

Commit 31b545e

Browse files
committed
Fix other cases where we return an Hex string on all kind of exceptions
1 parent 01b00b0 commit 31b545e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/StackExchange.Redis/RedisChannel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,12 @@ public static implicit operator RedisChannel(byte[]? key)
302302
{
303303
return Encoding.UTF8.GetString(arr);
304304
}
305-
catch
305+
catch (Exception e) when // Only catch exception throwed by Encoding.UTF8.GetString
306+
(e is DecoderFallbackException
307+
|| e is ArgumentException
308+
|| e is ArgumentNullException)
306309
{
307-
return BitConverter.ToString(arr);
310+
return BitConverter.ToString(arr);
308311
}
309312
}
310313

src/StackExchange.Redis/RedisKey.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,12 @@ public static implicit operator RedisKey(byte[]? key)
299299
{
300300
return Encoding.UTF8.GetString(arr, 0, length);
301301
}
302-
catch
302+
catch (Exception e) when // Only catch exception throwed by Encoding.UTF8.GetString
303+
(e is DecoderFallbackException
304+
|| e is ArgumentException
305+
|| e is ArgumentNullException)
303306
{
304-
return BitConverter.ToString(arr, 0, length);
307+
return BitConverter.ToString(arr, 0, length);
305308
}
306309
}
307310
}

0 commit comments

Comments
 (0)