MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / shouldRetry

Method shouldRetry

scripts/update-template.js:494–519  ·  view source on GitHub ↗

* 判断是否应该重试 * @param {Error} error * @returns {boolean}

(error)

Source from the content-addressed store, hash-verified

492 * @returns {boolean}
493 */
494 shouldRetry(error) {
495 // 不重试的错误类型
496 const noRetryErrors = [
497 ErrorTypes.API_KEY_MISSING,
498 ErrorTypes.PARSE_ERROR,
499 ErrorTypes.INVALID_RESPONSE
500 ];
501
502 if (error.type && noRetryErrors.includes(error.type)) {
503 return false;
504 }
505
506 // 网络错误和超时错误可以重试
507 if (error.type === ErrorTypes.NETWORK_ERROR ||
508 error.type === ErrorTypes.TIMEOUT_ERROR ||
509 error.type === ErrorTypes.RATE_LIMIT) {
510 return true;
511 }
512
513 // 5xx 错误可以重试
514 if (error.details && error.details.statusCode >= 500) {
515 return true;
516 }
517
518 return false;
519 }
520
521 /**
522 * 生成内容

Callers 1

executeWithRetryMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected