-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
It seems that API responses that have a HTTP status of 4xx or 5xx, but don't include a statusCode field in the JSON body, are considered success responses.
Both responseIsError and responseIsLegacyError return false when statusCode is missing.
javascript-api/src/api-base.ts
Lines 72 to 96 in a04aa38
| function responseIsLegacyError( | |
| response: ApiResponse, | |
| ): response is LegacyErrorResponse { | |
| return ( | |
| response.statusCode && | |
| Math.floor(response.statusCode / 100) !== 2 && | |
| !Object.prototype.hasOwnProperty.call(response, 'error') | |
| ); | |
| } | |
| /** | |
| * Returns true if an ApiResponse is an ClientErrorResponse response, usable as a type guard. | |
| * @param response an ApiResponse to narrow down | |
| * @returns true if the ApiResponse is an ClientErrorResponse, false if it is a SuccessResponse | |
| * @hidden | |
| */ | |
| function responseIsClientError( | |
| response: ApiResponse, | |
| ): response is ClientErrorResponse { | |
| return ( | |
| response.statusCode && | |
| Math.floor(response.statusCode / 100) === 4 && | |
| Object.prototype.hasOwnProperty.call(response, 'error') | |
| ); | |
| } |