Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: domain error handler #159

Merged
merged 9 commits into from
Jan 19, 2024
Merged

Feat: domain error handler #159

merged 9 commits into from
Jan 19, 2024

Conversation

elizachi
Copy link
Contributor

@elizachi elizachi commented Jan 11, 2024

Added a decorator for custom errors and a domain-level error handler. Now if a domain-level error is received, it will be categorized in a certain way.

@elizachi elizachi changed the title Feat/domain error handler Feat: domain error handler Jan 11, 2024
Copy link
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to separate Domain Errors and other 5xx errors. Domain Errors — special exceptions provided by business logic in domain level.

  • Create DomainError entity
  • Change default Errors trown in a domain-level to DomainErrors
  • Catch DomainErrors in setErrorHandler and reply with special format
  • All other errors should be throwed as usual

@elizachi elizachi requested a review from neSpecc January 13, 2024 18:46
@elizachi elizachi force-pushed the feat/domain-error-handler branch from 1daa1d4 to 38f2c23 Compare January 13, 2024 19:12
src/domain/entities/domainError.ts Outdated Show resolved Hide resolved
src/presentation/http/decorators/domainError.ts Outdated Show resolved Hide resolved
src/presentation/http/fastify.d.ts Outdated Show resolved Hide resolved
decorator domainError status code changed to 400
added a real try-catch example
@elizachi elizachi requested a review from neSpecc January 13, 2024 20:18
@elizachi elizachi requested a review from neSpecc January 14, 2024 07:33
@elizachi elizachi self-assigned this Jan 14, 2024
src/domain/entities/DomainError.ts Outdated Show resolved Hide resolved
src/presentation/http/decorators/domainError.ts Outdated Show resolved Hide resolved
src/presentation/http/decorators/domainError.ts Outdated Show resolved Hide resolved
@neSpecc
Copy link
Member

neSpecc commented Jan 14, 2024

Have you updated all existing domain exceptions? I see only Note service

@neSpecc
Copy link
Member

neSpecc commented Jan 14, 2024

There were also some todo's left for domain-errors catching. They should be resolved and removed in this PR

@elizachi
Copy link
Contributor Author

elizachi commented Jan 15, 2024

There were also some todo's left for domain-errors catching. They should be resolved and removed in this PR

I found only one todo about this. Other tudo's contain either other tasks or are not at the domain level (like todo in src/repository/transport/open-api/index.ts or src/repository/transport/google-api/index.ts)

@elizachi elizachi requested a review from neSpecc January 15, 2024 17:27
@elizachi elizachi merged commit 3565d37 into main Jan 19, 2024
4 checks 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.

4 participants