Skip to content

Commit 41ec155

Browse files
Potential fix for code scanning alert no. 35: Generic catch clause
Solving a generic catch clause by expanding to all relevant exception types Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 89d2618 commit 41ec155

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/TypeGuard.Core/Rules/StringRules.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,23 @@ public bool IsValid(string value)
329329
string fullPath = Path.GetFullPath(value);
330330
return !mustExist || File.Exists(fullPath);
331331
}
332-
catch
332+
catch (ArgumentException)
333+
{
334+
return false;
335+
}
336+
catch (ArgumentNullException)
337+
{
338+
return false;
339+
}
340+
catch (PathTooLongException)
341+
{
342+
return false;
343+
}
344+
catch (NotSupportedException)
345+
{
346+
return false;
347+
}
348+
catch (IOException)
333349
{
334350
return false;
335351
}

0 commit comments

Comments
 (0)