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

Function checkResponse

build-system/tasks/bundle-size/index.js:65–73  ·  view source on GitHub ↗

* Checks the response of an operation. Throws if there's an error, and prints * success messages if not. * @param {!Response} response * @param {...string} successMessages * @return {Promise }

(response, ...successMessages)

Source from the content-addressed store, hash-verified

63 * @return {Promise<void>}
64 */
65async function checkResponse(response, ...successMessages) {
66 if (!response.ok) {
67 throw new Error(
68 `${response.status} ${response.statusText}: ${await response.text()}`
69 );
70 } else {
71 log(...successMessages);
72 }
73}
74
75/**
76 * Does a JSON POST request.

Callers 3

storeBundleSizeFunction · 0.85
skipBundleSizeFunction · 0.85
reportBundleSizeFunction · 0.85

Calls 2

logFunction · 0.50
textMethod · 0.45

Tested by

no test coverage detected