Skip to content

Commit

Permalink
catch all exception
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmy77 committed Jan 26, 2025
1 parent 6ce826a commit 86f3e13
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/modules/Hosts/Hosts.FuzzTests/FuzzTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using HostsUILib.Helpers;
using HostsUILib.HostsService;
// using HostsUILib.HostsService;

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

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

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

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

//
public static void FuzzWriteAsync(ReadOnlySpan<byte> input)
{
var additionalLines = System.Text.Encoding.UTF8.GetString(input);
var entries = new List<Entry>();
entries.Add(new Entry(0, System.Text.Encoding.UTF8.GetString(input)));
HostsService.WriteAsync(additionalLines, entries).Wait();
// public static void FuzzWriteAsync(ReadOnlySpan<byte> input)
// {
// var additionalLines = System.Text.Encoding.UTF8.GetString(input);
// var entries = new List<Entry>();
// entries.Add(new Entry(0, System.Text.Encoding.UTF8.GetString(input)));
// HostsService.WriteAsync(additionalLines, entries).Wait();


}
// }

}
}

1 comment on commit 86f3e13

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (1)

mengyuanchen

These words are not needed and should be removed accctrl aclapi appdata Appium appmodel atlbase atlcom atlfile atlstr bootstrapper caniuse ceq cguid Cmds cne codicon comdef commandline commctrl commdlg comutil consts cppwinrt CRSEL crx dcommon dcomp DCs desktopwindowxamlsource devpkey dxgidebug dxgiformat emmintrin Emoji endpointvolume evntrace exdisp Functiondiscoverykeys guiddef hinstance hstring Intelli junja Knownfolders lmcons LONGLONG lpt LTRB mfapi mfidl mfobjects mftransform Minimatch mmdeviceapi mmsystem msedge msiquery newdev nodoc notlike Objbase objidl pathcch Pnp Preinstalled processthreadsapi propkey propvarutil redistributable Renamer reparse restrictederrorinfo roadmap ruleset runtimes shellapi shellscalingapi shldisp shlobj stl strsafe strutil subquery SWC tailwindcss tapp thumbcache tlhelp Toolset touchpad Tsd uninstantiated uniquifier Unknwn unregistering urlmon USERDATA Uxtheme verrsrc wcautil wincodec Wincodecsdk windef windowsapp windowsx winerror winevt winsdkver winternl wsl wtsapi

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:microsoft/PowerToys.git repository
on the dev/mengyuanchen/add_onefuzz/hostfile branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/12969902359/attempts/1'
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.