Add a public StreamApiException constructor#215
Merged
sierpinskid merged 1 commit intoJun 30, 2026
Conversation
StreamApiException is a public, catch-and-branch type (consumers inspect StatusCode/Code and branch via the StreamApiExceptionExtensions.Is* helpers), but its only constructor was internal and took the internal APIErrorInternalDTO, so integrators could not construct one to unit-test their own error handling (e.g. simulating a 403 / code 70 'no access to channels' response). Add a public constructor over the type's already-public fields. Both it and the existing DTO constructor funnel through one private constructor and a shared BuildMessage helper, so the Exception.Message format is identical however the exception is built. APIErrorInternalDTO stays internal.
sierpinskid
approved these changes
Jun 30, 2026
Member
Member
|
Thank you for you contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StreamApiExceptionis a public, catch-and-branch type — integrators are expected tocatchit, inspectStatusCode/Code, and branch via the publicStreamApiExceptionExtensions.Is*helpers (IsNoAccessToChannelsError,IsRateLimitExceededError, etc.). But its only constructor isinternaland takes theinternalAPIErrorInternalDTO, so integrators can't construct one to unit-test their own error handling.This means there's no supported way to write a test like "when a channel-hydration call throws a 403 / code 70, my code drops the channel from the local list instead of rethrowing" — you can't produce the exception to feed your handler without reaching into SDK internals (e.g. an
InternalsVisibleTopatch against a vendored copy).This PR adds a public constructor over the type's already-public fields.
APIErrorInternalDTOstays internal.Change
Both this and the existing DTO constructor funnel through a single private constructor and a shared
BuildMessagehelper, so theException.Messageformat is identical regardless of how the exception is built (keeps log/crash-report grouping consistent). Every parameter maps 1:1 to an existing public property; nothing internal is exposed.Why this shape
ForTesting-style factory) is idiomatic for anExceptionsubclass and reads naturally at call sites. Hand-constructing a representative API error is legitimately useful beyond tests (fakes, mocks, replay tooling).APIErrorInternalDTOis kept internal as requested.Integrator impact (before → after)
Before — only possible by granting
InternalsVisibleToto the SDK and using the internal DTO:After — public API only:
Testing
Exception.Messageoutput to the previous inline code across all error shapes (null message/moreInfo, null/empty/multi-entryexceptionFields).Changelog
Added an entry under
Unreleased / Features.