* 处理系统执行错误 * * 记录错误信息并跟踪错误次数。当系统错误次数超过阈值时自动禁用该系统。 * * @param system 出错的系统 * @param phase 错误发生的阶段(update 或 lateUpdate) * @param error 错误对象
(system: EntitySystem, phase: 'update' | 'lateUpdate', error: unknown)
| 598 | * @param error 错误对象 |
| 599 | */ |
| 600 | private _handleSystemError(system: EntitySystem, phase: 'update' | 'lateUpdate', error: unknown): void { |
| 601 | const errorCount = (this._systemErrorCount.get(system) || 0) + 1; |
| 602 | this._systemErrorCount.set(system, errorCount); |
| 603 | |
| 604 | const name = system.systemName; |
| 605 | this._logger.error( |
| 606 | `Error in system ${name}.${phase}() [${errorCount}/${this._maxErrorCount}]:`, |
| 607 | error |
| 608 | ); |
| 609 | |
| 610 | if (errorCount >= this._maxErrorCount) { |
| 611 | system.enabled = false; |
| 612 | this._logger.error( |
| 613 | `System ${name} has been disabled due to excessive errors (${errorCount} errors)` |
| 614 | ); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * 将实体添加到此场景,并返回它 |
no test coverage detected