Skip to content

feat!: throw discriminable errors indicating point of failure#95

Merged
mnahkies merged 3 commits intomainfrom
mn/feat/discriminable-errors
Dec 2, 2023
Merged

feat!: throw discriminable errors indicating point of failure#95
mnahkies merged 3 commits intomainfrom
mn/feat/discriminable-errors

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 force-pushed the mn/feat/discriminable-errors branch from ca1a4d1 to 0f766ab Compare December 2, 2023 09:52
@mnahkies mnahkies enabled auto-merge (squash) December 2, 2023 09:53
@mnahkies mnahkies merged commit 4badd41 into main Dec 2, 2023
@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.

1 participant