Skip to content

Avoid throwing System.Exception directly in user code #679

@ziagham

Description

@ziagham

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions