Skip to content

Commit 86f3e13

Browse files
committed
catch all exception
1 parent 6ce826a commit 86f3e13

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/modules/Hosts/Hosts.FuzzTests/FuzzTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44
using System;
55
using HostsUILib.Helpers;
6-
using HostsUILib.HostsService;
6+
// using HostsUILib.HostsService;
77

88
namespace Hosts.FuzzTests
99
{
@@ -19,7 +19,7 @@ public static void FuzzValidIPv4(ReadOnlySpan<byte> input)
1919

2020
// Console.WriteLine($"Input:{address}, ValidIPv4:{isValid}");
2121
}
22-
catch (Exception ex) when (ex is ArgumentException)
22+
catch (Exception ex)
2323
{
2424
// This is an example. It's important to filter out any *expected* exceptions from our code here.
2525
// However, catching all exceptions is considered an anti-pattern because it may suppress legitimate
@@ -39,7 +39,7 @@ public static void FuzzValidIPv6(ReadOnlySpan<byte> input)
3939

4040
// Console.WriteLine($"Input:{address}, ValidIPv6:{isValid}");
4141
}
42-
catch (Exception ex) when (ex is ArgumentException)
42+
catch (Exception ex)
4343
{
4444
// This is an example. It's important to filter out any *expected* exceptions from our code here.
4545
// However, catching all exceptions is considered an anti-pattern because it may suppress legitimate
@@ -58,7 +58,7 @@ public static void FuzzValidHosts(ReadOnlySpan<byte> input)
5858

5959
// Console.WriteLine($"Input:{hosts}, ValidHosts:{isValid}");
6060
}
61-
catch (Exception ex) when (ex is ArgumentException)
61+
catch (Exception ex) when (ex is OutOfMemoryException)
6262
{
6363
// This is an example. It's important to filter out any *expected* exceptions from our code here.
6464
// However, catching all exceptions is considered an anti-pattern because it may suppress legitimate
@@ -69,15 +69,15 @@ public static void FuzzValidHosts(ReadOnlySpan<byte> input)
6969
}
7070

7171
//
72-
public static void FuzzWriteAsync(ReadOnlySpan<byte> input)
73-
{
74-
var additionalLines = System.Text.Encoding.UTF8.GetString(input);
75-
var entries = new List<Entry>();
76-
entries.Add(new Entry(0, System.Text.Encoding.UTF8.GetString(input)));
77-
HostsService.WriteAsync(additionalLines, entries).Wait();
72+
// public static void FuzzWriteAsync(ReadOnlySpan<byte> input)
73+
// {
74+
// var additionalLines = System.Text.Encoding.UTF8.GetString(input);
75+
// var entries = new List<Entry>();
76+
// entries.Add(new Entry(0, System.Text.Encoding.UTF8.GetString(input)));
77+
// HostsService.WriteAsync(additionalLines, entries).Wait();
7878

7979

80-
}
80+
// }
8181

8282
}
8383
}

0 commit comments

Comments
 (0)