Error thrown when an HTTP response has a non-2xx status. Carries the numeric
status so callers can branch on it (e.g. retrying a 403 WAF cookie
challenge) rather than string-matching the message.
Param: status
The HTTP status code (e.g. 403)
Param: statusText
The HTTP status text (e.g. "Forbidden")
Param: body
The (truncated) response body, when it could be read
Returns
The HttpError instance
Example
try { awaitfetchDecorator(url); } catch (error) { if (error instanceofHttpError&& error.status ===403) { // retry the request } if (error instanceofHttpError&& error.body?.includes('INVALID_API_KEY')) { // the API told us why it refused the request } }
Error thrown when an HTTP response has a non-2xx status. Carries the numeric status so callers can branch on it (e.g. retrying a
403WAF cookie challenge) rather than string-matching the message.Param: status
The HTTP status code (e.g. 403)
Param: statusText
The HTTP status text (e.g. "Forbidden")
Param: body
The (truncated) response body, when it could be read
Returns
The HttpError instance
Example
Source