MCPcopy Index your code
hub / github.com/ampproject/amphtml / assertSuccess

Function assertSuccess

third_party/subscriptions-project/swg.js:13587–13601  ·  view source on GitHub ↗

* Returns the response if successful or otherwise throws an error. * @param {!FetchResponse} response * @return {!Promise<!FetchResponse>} * @private Visible for testing

(response)

Source from the content-addressed store, hash-verified

13585 * @private Visible for testing
13586 */
13587function assertSuccess(response) {
13588 return new Promise((resolve) => {
13589 if (response.ok) {
13590 return resolve(response);
13591 }
13592
13593 const {status} = response;
13594 const err = new Error(`HTTP error ${status}`);
13595 err.retriable = isRetriable(status);
13596 // TODO(@jridgewell, #9448): Callers who need the response should
13597 // skip processing.
13598 err.response = response;
13599 throw err;
13600 });
13601}
13602
13603/**
13604 * Response object in the Fetch API.

Callers 1

fetchMethod · 0.70

Calls 2

isRetriableFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected