Skip to content

Add error handling middleware#126

Merged
czechboy0 merged 19 commits intoapple:mainfrom
gayathrisairam:error_handling_middleware
Nov 20, 2024
Merged

Add error handling middleware#126
czechboy0 merged 19 commits intoapple:mainfrom
gayathrisairam:error_handling_middleware

Conversation

@gayathrisairam
Copy link
Copy Markdown
Contributor

Motivation

Implementation of Improved error handling proposal

Modifications

Added HTTPResponseConvertible protocol
Added ErrorHandlingMiddleware that converts errors confirming to HTTPResponseConvertible to a HTTP response.

Result

The new middleware is an opt-in middleware. So there won't be any change to existing clients.
Clients who wish to have OpenAPI error handling can include the new error middleware in their application.

Test Plan

Added E2E tests to test the new middleware.

Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
Copy link
Copy Markdown
Collaborator

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up @gayathrisairam!

I've left some initial comments / questions, and a note on how you can run the linters locally.

Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift
Copy link
Copy Markdown
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

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

Looks great overall, added a few suggestions for more polish, mainly in the doc comments.

Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
@gayathrisairam gayathrisairam force-pushed the error_handling_middleware branch from d235fb3 to 60cb9b9 Compare November 19, 2024 00:25
Copy link
Copy Markdown
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, added a few more minor suggestions as part of the final pass

Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Sources/OpenAPIRuntime/Interface/ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
Comment thread Tests/OpenAPIRuntimeTests/Interface/Test_ErrorHandlingMiddleware.swift Outdated
@czechboy0
Copy link
Copy Markdown
Contributor

@gayathrisairam please rerun the formatter and unit tests, those are failing

Gayathri Sairamkrishnan and others added 19 commits November 20, 2024 12:33
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
…re.swift

Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>
@gayathrisairam gayathrisairam force-pushed the error_handling_middleware branch from 0eeeb48 to 4e7c638 Compare November 20, 2024 12:35
@czechboy0
Copy link
Copy Markdown
Contributor

Looks great, thank you @gayathrisairam! 👏

@czechboy0 czechboy0 merged commit 3d5d957 into apple:main Nov 20, 2024
@czechboy0 czechboy0 added the 🆕 semver/minor Adds new public API. label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants