refactor(errors): separate ApiError from RequestError#260
Conversation
Introduce ApiError (extends RequestError) for structured Server API error responses, carrying the strongly typed errorCode. TooManyRequestsError now extends ApiError. 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. Runtime note: on the proxy/unknown path, errorCode previously reflected response.statusText and is now absent.
🦋 Changeset detectedLatest commit: 8baa87a 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 |
🚀 Following releases will be created using changesets from this PR:@fingerprint/node-sdk@7.5.0Minor Changes
|
Coverage report
Test suite run success78 tests passing in 22 suites. Report generated by 🧪jest coverage report action from 8baa87a Show full coverage report
|
ApiError extends RequestError, thrown for structured Server API error responses; it carries the strongly typederrorCode(ErrorCode) andresponseBody: ErrorResponse.TooManyRequestsErrornow extendsApiError; the client throwsApiErrorfor structured responses.RequestErrorbecomes the base for request-level errors, thrown directly for non–Server-API responses (e.g. an intermediate proxy). It no longer declareserrorCode.ApiError/ErrorCodenarrowing.Stacked on #251
Base is the strongly-typed-
errorCodebranch (#251). Review/merge #251 first; this PR's diff is only the error separation.Runtime change: proxy-path
errorCodeOn the non–Server-API 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.