* @param {string} input URL * @param {?FetchInitDef} init Fetch options object. * @return {!Promise<!FetchResponse>}
(input, init)
| 13433 | * @return {!Promise<!FetchResponse>} |
| 13434 | */ |
| 13435 | fetch(input, init) { |
| 13436 | init = setupInit(init); |
| 13437 | return this.fetch_(input, init) |
| 13438 | .catch((reason) => { |
| 13439 | /* |
| 13440 | * If the domain is not valid for SwG we return 404 without |
| 13441 | * CORS headers and the browser throws a CORS error. |
| 13442 | * We include some helpful text in the message to point the |
| 13443 | * publisher towards the real problem. |
| 13444 | */ |
| 13445 | const targetOrigin = parseUrl(input).origin; |
| 13446 | throw new Error( |
| 13447 | `XHR Failed fetching (${targetOrigin}/...): (Note: a CORS error above may indicate that this publisher or domain is not configured in Publisher Center. The CORS error happens becasue 4xx responses do not set CORS headers.)`, |
| 13448 | reason && reason.message |
| 13449 | ); |
| 13450 | }) |
| 13451 | .then((response) => assertSuccess(response)); |
| 13452 | } |
| 13453 | } |
| 13454 | |
| 13455 | /** |
no test coverage detected