-
Notifications
You must be signed in to change notification settings - Fork 26
Avoid throwing System.Exception directly in user code #679
Copy link
Copy link
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workingcode cleanupcleaning-up codecleaning-up codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring codereliability
Description
What version of FlowSynx?
1.2.2
Describe the bug
File: plugins/FlowSynx.Plugins.LocalFileSystem/Services/LocalFileManager.cs
Lines: 99, 102, 119, 122, 125, 139, 153, 156, 159, 179, 182, 185, 204, 207, 210, 228, 231, 255, 263, 270, 277, 338, 341, 346
Currently, the code throws a general System.Exception:
throw new Exception(Resources.something);Throwing System.Exception directly is discouraged because it is too generic and makes error handling harder.
Suggested Fix (example)
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException(Resources.something,);
}Do it for all lines aboved-mentioned.
Benefits
- Improves code clarity and debugging.
- Allows consumers to catch more specific exceptions.
- Follows .NET best practices.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workingcode cleanupcleaning-up codecleaning-up codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring codereliability