MCPcopy
hub / github.com/ampproject/amphtml / assertSuccess

Function assertSuccess

src/utils/xhr-utils.js:365–379  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

363 * @return {!Promise<!Response>}
364 */
365export function assertSuccess(response) {
366 return new Promise((resolve) => {
367 if (response.ok) {
368 return resolve(response);
369 }
370
371 const {status} = response;
372 const err = user().createError(`HTTP error ${status}`);
373 err['retriable'] = isRetriable(status);
374 // TODO(@jridgewell, #9448): Callers who need the response should
375 // skip processing.
376 err['response'] = response;
377 throw err;
378 });
379}

Callers 4

test-xhr.jsFile · 0.90
xhrRequestFunction · 0.90
fetchMethod · 0.90
sendSignalMethod · 0.90

Calls 4

userFunction · 0.90
isRetriableFunction · 0.70
resolveFunction · 0.50
createErrorMethod · 0.45

Tested by

no test coverage detected