Fix action error handling

This commit is contained in:
Anton Vakhrushev 2020-04-04 13:32:14 +03:00
parent 4bf8161b70
commit 6e85f9f443

View File

@ -1,6 +1,6 @@
import { markPage, sleepShort, timestamp } from './utils'; import { markPage, sleepShort, timestamp } from './utils';
import { UpgradeBuildingTask } from './Task/UpgradeBuildingTask'; import { UpgradeBuildingTask } from './Task/UpgradeBuildingTask';
import { AbortTaskError, BuildingQueueFullError, TryLaterError } from './Errors'; import { AbortTaskError, ActionError, BuildingQueueFullError, TryLaterError } from './Errors';
import { Task, TaskId, TaskList, TaskQueue } from './Storage/TaskQueue'; import { Task, TaskId, TaskList, TaskQueue } from './Storage/TaskQueue';
import { ActionQueue } from './Storage/ActionQueue'; import { ActionQueue } from './Storage/ActionQueue';
import { Command } from './Common'; import { Command } from './Common';
@ -101,7 +101,6 @@ export class Scheduler {
} }
private handleError(err: Error) { private handleError(err: Error) {
this.logWarn('ACTION ABORTED', err.message);
this.actionQueue.clear(); this.actionQueue.clear();
if (err instanceof AbortTaskError) { if (err instanceof AbortTaskError) {
@ -125,6 +124,11 @@ export class Scheduler {
return; return;
} }
if (err instanceof ActionError) {
this.logWarn('ACTION ABORTED', err.message);
return;
}
this.logError(err.message); this.logError(err.message);
throw err; throw err;
} }