You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improved enriched error propagation from the transport and middlewares (#63)
Improved enriched error propagation from the transport and middlewares
### Motivation
Fixesapple/swift-openapi-generator#302 and apple/swift-openapi-generator#17.
The issue was that we hid away errors thrown in transports and middlewares, and the adopter would get `ClientError` where the `underlyingError` wasn't the error thrown by the underlying transport/middleware, but instead a private wrapper of ours.
### Modifications
Make sure `{Client,Server}Error.underlyingError` contains the error thrown from the underlying transport/middleware when that was the cause of the error, otherwise keep `RuntimeError` there as was the behavior until now.
Also added a `causeDescription` property on both public error types to allow communicating the context for the underlying error.
Also made sure middleware errors are now wrapped in Client/ServerError, they weren't before so didn't contain the context necessary to debug issues well.
### Result
Adopters can now extract the errors thrown e.g. by URLSession from our public error types using the `underlyingError` property and understand the context of where it was thrown by checking the user-facing `causeDescription`.
Also, adopters now get enriched errors thrown from middlewares.
### Test Plan
Wrote unit tests for both UniversalClient and UniversalServer, inevitably found some minor bugs there as well, fixed them all, plus the unit tests now verify the behavior new in this PR.
Reviewed by: glbrntt
Builds:
✔︎ pull request validation (5.10) - Build finished.
✔︎ pull request validation (5.8) - Build finished.
✔︎ pull request validation (5.9) - Build finished.
✔︎ pull request validation (docc test) - Build finished.
✔︎ pull request validation (integration test) - Build finished.
✔︎ pull request validation (nightly) - Build finished.
✔︎ pull request validation (soundness) - Build finished.
✖︎ pull request validation (api breakage) - Build finished.
#63
0 commit comments