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 launch7: Completed8: Cancelled9: Active11: 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
| Parameter | Type | Description |
|---|---|---|
currentState | string | Current state of the campaign |
attemptedAction | string | Action that was attempted (start, pause, stop, delete) |
validStates? | string[] | Optional list of valid states for this action |
response? | unknown | API response body if available |
requestId? | string | Correlation ID for debugging |
Returns
InvalidCampaignStateError
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="statuscode"></a> statusCode? | readonly | number | HTTP status code if applicable | WBAPIError.statusCode | errors/base-error.ts:25 |
<a id="response"></a> response? | readonly | unknown | API response body if available | WBAPIError.response | errors/base-error.ts:30 |
<a id="requestid"></a> requestId? | readonly | string | Correlation ID for debugging and tracing requests | WBAPIError.requestId | errors/base-error.ts:35 |
<a id="currentstate"></a> currentState | readonly | string | Current campaign state | - | errors/promotion-errors.ts:364 |
<a id="attemptedaction"></a> attemptedAction | readonly | string | Action that was attempted | - | errors/promotion-errors.ts:369 |
<a id="validstates"></a> validStates? | readonly | string[] | 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
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;
}| Name | Type | Defined in |
|---|---|---|
name | string | errors/promotion-errors.ts:437 |
message | string | errors/promotion-errors.ts:438 |
statusCode | number | errors/promotion-errors.ts:439 |
currentState | string | errors/promotion-errors.ts:440 |
attemptedAction | string | errors/promotion-errors.ts:441 |
validStates? | string[] | errors/promotion-errors.ts:442 |
response? | unknown | errors/promotion-errors.ts:443 |
requestId? | string | errors/promotion-errors.ts:444 |