Refactoring task errors
This commit is contained in:
		@@ -1,15 +1,13 @@
 | 
			
		||||
import { ActionController, registerAction } from './ActionController';
 | 
			
		||||
import { AbortTaskError } from '../Errors';
 | 
			
		||||
import { AbortTaskError, taskError } from '../Errors';
 | 
			
		||||
import { Args } from '../Queue/Args';
 | 
			
		||||
import { Task } from '../Queue/TaskProvider';
 | 
			
		||||
 | 
			
		||||
@registerAction
 | 
			
		||||
export class ClickButtonAction extends ActionController {
 | 
			
		||||
    async run(args: Args, task: Task): Promise<any> {
 | 
			
		||||
        if (!args.selector) {
 | 
			
		||||
            throw new AbortTaskError('No selector');
 | 
			
		||||
        }
 | 
			
		||||
        const el = jQuery(args.selector);
 | 
			
		||||
        const selector = args.selector || taskError('No selector');
 | 
			
		||||
        const el = jQuery(selector);
 | 
			
		||||
        if (el.length === 1) {
 | 
			
		||||
            console.log('CLICK BUTTON', el);
 | 
			
		||||
            el.trigger('click');
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,12 @@
 | 
			
		||||
import { ActionController, registerAction } from './ActionController';
 | 
			
		||||
import { AbortTaskError } from '../Errors';
 | 
			
		||||
import { taskError } from '../Errors';
 | 
			
		||||
import { Args } from '../Queue/Args';
 | 
			
		||||
import { Task } from '../Queue/TaskProvider';
 | 
			
		||||
 | 
			
		||||
@registerAction
 | 
			
		||||
export class GoToPageAction extends ActionController {
 | 
			
		||||
    async run(args: Args, task: Task): Promise<any> {
 | 
			
		||||
        if (!args.path) {
 | 
			
		||||
            throw new AbortTaskError('No path');
 | 
			
		||||
        }
 | 
			
		||||
        window.location.assign(args.path);
 | 
			
		||||
        const path = args.path || taskError('Empty path');
 | 
			
		||||
        window.location.assign(path);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import { ActionController, registerAction } from './ActionController';
 | 
			
		||||
import { AbortTaskError, ActionError, TryLaterError } from '../Errors';
 | 
			
		||||
import { AbortTaskError, ActionError, taskError, TryLaterError } from '../Errors';
 | 
			
		||||
import { grabResourceDeposits } from '../Page/SlotBlock';
 | 
			
		||||
import { UpgradeBuildingTask } from '../Task/UpgradeBuildingTask';
 | 
			
		||||
import { ResourceDeposit } from '../Game';
 | 
			
		||||
@@ -15,10 +15,7 @@ export class UpgradeResourceToLevel extends ActionController {
 | 
			
		||||
            throw new ActionError('No deposits');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const villageId = args.villageId;
 | 
			
		||||
        if (villageId === undefined) {
 | 
			
		||||
            throw new AbortTaskError('No village id');
 | 
			
		||||
        }
 | 
			
		||||
        const villageId = args.villageId || taskError('No village id');
 | 
			
		||||
 | 
			
		||||
        const requiredLevel = getNumber(args.level);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user