* Report step error. * @param {number} step * @param {string} errorMessage
(step, errorMessage)
| 314 | * @param {string} errorMessage |
| 315 | */ |
| 316 | function reportError(step, errorMessage) { |
| 317 | console.error(LOG_PREFIX, `步骤 ${step} 失败: ${errorMessage}`); |
| 318 | log(`步骤 ${step} 失败:${errorMessage}`, 'error'); |
| 319 | const message = { |
| 320 | type: 'STEP_ERROR', |
| 321 | source: SCRIPT_SOURCE, |
| 322 | step, |
| 323 | payload: {}, |
| 324 | error: errorMessage, |
| 325 | }; |
| 326 | Promise.resolve(chrome.runtime.sendMessage(message)) |
| 327 | .then((response) => { |
| 328 | console.log(LOG_PREFIX, `STEP_ERROR sent successfully for step ${step}`, { |
| 329 | response, |
| 330 | url: location.href, |
| 331 | errorMessage, |
| 332 | }); |
| 333 | }) |
| 334 | .catch((err) => { |
| 335 | console.error(LOG_PREFIX, `STEP_ERROR send failed for step ${step}`, err?.message || err, { |
| 336 | url: location.href, |
| 337 | errorMessage, |
| 338 | }); |
| 339 | }); |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Simulate a click with proper event dispatching. |
no test coverage detected