Skip to content

Refactor Opportunity validation to use custom exceptions #692

@sonalguptaabd-bit

Description

@sonalguptaabd-bit

Summary

Opportunity validation currently uses addError directly inside the validation
service, which mixes validation logic with user-facing error handling.

Suggested Solution

Refactor Opportunity validation to throw custom exception classes
(e.g., OpportunityValidationException) from the validation service.

Catch these exceptions in the OpportunityTriggerHandler and surface
user-friendly messages using addError, improving separation of concerns
and aligning with the handler/service pattern used in this repository.

Alternative Solutions

Continue using addError directly in the validation service, but this would
keep business validation logic tightly coupled with UI error handling.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions