Skip to content

Feature/exceptions+error handling - #38

Merged
jianmingf merged 6 commits into
devfrom
feature/Exceptions+errorHandling
Dec 18, 2025
Merged

jianmingf merged 6 commits into
devfrom
feature/Exceptions+errorHandling

Conversation

@LuisCartucho

Copy link
Copy Markdown
Collaborator

API Exception & Test Refactor

This PR standardizes error handling and service test behavior across the entire API.

API changes

Introduced a centralized API exception model using ApiException and ApiErrors

Services now throw semantic, HTTP-aware exceptions (400, 401, 404, 409) instead of generic .NET exceptions

Removed scattered try/catch blocks from services and rely on global exception middleware

Aligned service method contracts with clear API semantics

Test updates

Updated all service tests to assert ApiException instead of framework exceptions

Added explicit assertions for HTTP status codes where applicable

Renamed tests to reflect API behavior rather than implementation details

Ensured constructor usage matches current service dependencies

Why

Keeps controllers thin and services expressive

Ensures consistent, predictable error responses for clients

Improves test reliability and future-proofing

Makes error handling easier to reason about and extend

No functional behavior changes were introduced beyond error semantics and naming consistency.

@jianmingf
jianmingf merged commit 22a7773 into dev Dec 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants