Skip to content

Wildberries API TypeScript SDK / InvalidCampaignStateError

Class: InvalidCampaignStateError

Defined in: errors/promotion-errors.ts:360

Error thrown when attempting invalid campaign state transitions.

Campaign lifecycle states:

  • -1: Deleted (being deleted, will complete in 10 minutes)
  • 4: Ready to launch
  • 7: Completed
  • 8: Cancelled
  • 9: Active
  • 11: Paused

Valid transitions:

  • Ready (4) → Active (9) via startCampaign()
  • Active (9) → Paused (11) via pauseCampaign()
  • Paused (11) → Active (9) via startCampaign()
  • Active/Paused → Completed (7) via stopCampaign()

Example

typescript
import { InvalidCampaignStateError } from 'daytona-wildberries-typescript-sdk';

try {
  // Trying to start an already active campaign
  await sdk.promotion.startCampaign(123);
} catch (error) {
  if (error instanceof InvalidCampaignStateError) {
    console.error(`Cannot ${error.attemptedAction} campaign in ${error.currentState} state`);
    console.error('Valid states:', error.validStates);
  }
}

Extends

Constructors

Constructor

ts
new InvalidCampaignStateError(
   currentState: string, 
   attemptedAction: string, 
   validStates?: string[], 
   response?: unknown, 
   requestId?: string): InvalidCampaignStateError;

Defined in: errors/promotion-errors.ts:385

Creates an InvalidCampaignStateError

Parameters

ParameterTypeDescription
currentStatestringCurrent state of the campaign
attemptedActionstringAction that was attempted (start, pause, stop, delete)
validStates?string[]Optional list of valid states for this action
response?unknownAPI response body if available
requestId?stringCorrelation ID for debugging

Returns

InvalidCampaignStateError

Overrides

WBAPIError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
<a id="statuscode"></a> statusCode?readonlynumberHTTP status code if applicableWBAPIError.statusCodeerrors/base-error.ts:25
<a id="response"></a> response?readonlyunknownAPI response body if availableWBAPIError.responseerrors/base-error.ts:30
<a id="requestid"></a> requestId?readonlystringCorrelation ID for debugging and tracing requestsWBAPIError.requestIderrors/base-error.ts:35
<a id="currentstate"></a> currentStatereadonlystringCurrent campaign state-errors/promotion-errors.ts:364
<a id="attemptedaction"></a> attemptedActionreadonlystringAction that was attempted-errors/promotion-errors.ts:369
<a id="validstates"></a> validStates?readonlystring[]List of valid states for the attempted action-errors/promotion-errors.ts:374

Methods

getUserMessage()

ts
getUserMessage(): string;

Defined in: errors/promotion-errors.ts:404

Returns user-friendly error message with state transition guidance

Returns

string

Error message with valid state transitions

Overrides

WBAPIError.getUserMessage


toJSON()

ts
toJSON(): {
  name: string;
  message: string;
  statusCode: number;
  currentState: string;
  attemptedAction: string;
  validStates?: string[];
  response?: unknown;
  requestId?: string;
};

Defined in: errors/promotion-errors.ts:436

Custom JSON serialization

Returns

ts
{
  name: string;
  message: string;
  statusCode: number;
  currentState: string;
  attemptedAction: string;
  validStates?: string[];
  response?: unknown;
  requestId?: string;
}
NameTypeDefined in
namestringerrors/promotion-errors.ts:437
messagestringerrors/promotion-errors.ts:438
statusCodenumbererrors/promotion-errors.ts:439
currentStatestringerrors/promotion-errors.ts:440
attemptedActionstringerrors/promotion-errors.ts:441
validStates?string[]errors/promotion-errors.ts:442
response?unknownerrors/promotion-errors.ts:443
requestId?stringerrors/promotion-errors.ts:444

Overrides

WBAPIError.toJSON

Made with ❤️ for the Wildberries developer community