Skip to content

Avoid throwing System.Exception in user code in WorkflowValidator #766

@ziagham

Description

@ziagham

What version of FlowSynx?

1.2.5

Describe the bug

Throwing System.Exception directly is considered a bad practice because it is too generic and can make exception handling more difficult. It’s recommended to throw more specific exceptions or create a custom exception type that clearly communicates the error context.

File: src/FlowSynx.Infrastructure/Workflow/WorkflowValidator.cs
Line: 107

Current code

if (errors.Any())
{
    throw new Exception(string.Join(Environment.NewLine, errors));
}

Proposed fix

if (errors.Any())
{
    throw new InvalidOperationException(string.Join(Environment.NewLine, errors));
}

##Benefits:

  • Makes exception handling more predictable.
  • Improves readability and maintainability.
  • Enables callers to catch and handle specific exceptions appropriately.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions