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!: throw discriminable errors indicating point of failure #95

Merged
merged 3 commits into from
Dec 2, 2023

Conversation

mnahkies
Copy link
Owner

@mnahkies mnahkies commented Nov 11, 2023

Previously if request validation or response validation failed you'd just get something like a ZodError without much context as to where in the request processing failed.

This change introduced a KoaRuntimeError that wraps all exceptions thrown during request processing and annotates them with additional context via a phase property.

The intention is that you can then mount a generic error handling middleware that can distinguish between request validation errors, etc.

See integration-tests/typescript-koa/src/petstore-expanded.yaml.ts for an example.

Breaking change: errors thrown are now wrapped in KoaRuntimeError objects.

@mnahkies mnahkies enabled auto-merge (squash) December 2, 2023 09:53
@mnahkies mnahkies merged commit 4badd41 into main Dec 2, 2023
1 check passed
@mnahkies mnahkies deleted the mn/feat/discriminable-errors branch December 2, 2023 09:55
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.

None yet

1 participant