/** * An error that occurred during the execution of an app capability. */ export class ExecutionError extends Error { override readonly cause: unknown; constructor(cause: unknown) { super(`Error during app execution: ${cause}`); this.name = "ExecutionError"; this.cause = cause; } } /** Explicitly permit another workflow or step attempt. */ export class RetryableError extends Error { readonly retryAfterMs: number | undefined; constructor(message: string, options?: { retryAfterMs?: number }) { super(message); this.name = "RetryableError"; if ( options?.retryAfterMs !== undefined && (!Number.isFinite(options.retryAfterMs) || options.retryAfterMs < 0) ) { throw new Error("RetryableError retryAfterMs must be zero or greater."); } this.retryAfterMs = options?.retryAfterMs; } } /** Skip remaining workflow or step attempts. */ export class FatalError extends Error { constructor(message: string) { super(message); this.name = "FatalError"; } } /** Tell the platform that an external service asked the sync to slow down. */ export class RateLimitError extends ExecutionError { readonly retryAfter: number | undefined; constructor(options?: { retryAfter?: number }) { super("Rate limited by external API"); this.name = "RateLimitError"; this.retryAfter = options?.retryAfter; } }