Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

API error responses without statusCode are considered successful #338

Copy link
Copy link
@boxmein

Description

@boxmein
Issue body actions

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.

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')
);
}

Reactions are currently unavailable

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.