Skip to content

MI-326: Add ErrorThrowingClient type utility to microservice-util-lib#194

Merged
kai-nguyen-aligent merged 3 commits into
mainfrom
feat/MI-326-implement-throwing-client
Jun 12, 2026
Merged

MI-326: Add ErrorThrowingClient type utility to microservice-util-lib#194
kai-nguyen-aligent merged 3 commits into
mainfrom
feat/MI-326-implement-throwing-client

Conversation

@kai-nguyen-aligent

Copy link
Copy Markdown
Contributor

Description of the proposed changes

  • Add ErrorThrowingClient mapped type and asErrorThrowingClient cast function to @aligent/microservice-util-lib, co-located with retryMiddleware
  • ErrorThrowingClient rewrites HTTP method return types to Promise<{ data: D; response: Response }>, stripping the unreachable error branch when retryMiddleware is registered with throwOnNotOk: true (the default)
  • asErrorThrowingClient() is a zero-cost type narrowing — no runtime overhead
  • Also export HttpResponseError and isHttpResponseError from the package barrel, enabling consumers to handle expected error status codes via try/catch

Other solutions considered

  • Placing ErrorThrowingClient in consumer packages rather than microservice-util-lib — rejected because every project using retryMiddleware would need to define it independently

Notes to reviewers

  • 🛈 Toggl Code: MI-326: Code Review
  • 🛈 When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

@kai-nguyen-aligent kai-nguyen-aligent marked this pull request as ready for review June 12, 2026 02:54
@kai-nguyen-aligent kai-nguyen-aligent requested a review from a team as a code owner June 12, 2026 02:54
@kai-nguyen-aligent kai-nguyen-aligent merged commit 0295bdc into main Jun 12, 2026
2 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.

2 participants