-
Notifications
You must be signed in to change notification settings - Fork 26
Avoid throwing System.Exception in user code in WorkflowValidator #766
Copy link
Copy link
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring code
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring code