refactor(errors): separate ServerApiError from RequestError#260
refactor(errors): separate ServerApiError from RequestError#260JuroUhlar wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: a639fae The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage report
Test suite run success81 tests passing in 24 suites. Report generated by 🧪jest coverage report action from a639fae Show full coverage report
|
061290e to
3b91dd0
Compare
Introduce ServerApiError (extends RequestError) for structured Server API error responses, carrying the strongly typed errorCode (ErrorCode). TooManyRequestsError now extends ServerApiError. RequestError becomes the base for request-level errors and is thrown directly for non-Server-API responses (e.g. proxy errors), where no errorCode is available. Supersedes the base branch's LooseAutocomplete approach: since errorCode now lives only on ServerApiError (strictly typed), the widened errorCode on RequestError and the LooseAutocomplete helper are removed. Runtime note: on the proxy/unknown path, errorCode previously reflected response.statusText and is now absent.
3b91dd0 to
a639fae
Compare
🚀 Following releases will be created using changesets from this PR:@fingerprint/node-sdk@7.5.0Minor Changes
Patch Changes
|
ServerApiError extends RequestError, thrown for structured Server API error responses; it carries the strongly typederrorCode(ErrorCode) andresponseBody: ErrorResponse.TooManyRequestsErrornow extendsServerApiError.RequestErrorbecomes the base for request-level errors, thrown directly for non–Server-API responses (e.g. an intermediate proxy). It no longer declareserrorCode.ErrorCodetype; consolidate the error-handling changeset into one entry.LooseAutocomplete/typeUtils.ts, now superseded (see below).ServerApiError/ErrorCodenarrowing.Supersedes the base's
LooseAutocompleteapproachBase #251 kept
errorCodeonRequestError, widened toLooseAutocomplete<ErrorCode>with astatusTextplaceholder on the proxy path. This PR instead moveserrorCodetoServerApiErroronly (strictly typed), soRequestErrorhas noerrorCodeat all. That makesLooseAutocompletedead code, so it's removed here, and the two error changesets are folded into one coherent entry.Because this PR reverses part of its base, the stack is only coherent if #251 and this PR merge together. If #251 releases on its own first, we'd ship
LooseAutocompleteand then remove it. Consider collapsing the stack (or trimming #251 down to just theErrorCodeexport) before merging.Discussion point:
minorvsmajorOn the non–Server-API (proxy) path,
errorCodepreviously reflectedresponse.statusText; it is now absent (undefined). The compiler can't catch this for untyped consumers, so it's a runtime change, not just a type change — flagging against the repo's "runtime API follows semver strictly" note. Shipped asminor; happy to bump tomajorif preferred.Discussion point: class name
Named
ServerApiError(vs the previousApiError) to contrast withRequestErrorand make the "structured Server API error" meaning explicit. Easy to revert toApiErrorif preferred.