mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-21 01:25:29 +08:00
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import type { RunAttemptStatus, RunStatus } from './run';
|
|
|
|
export class RunStateMachineError extends Error {
|
|
constructor(message: string, public readonly code: string) {
|
|
super(message);
|
|
this.name = new.target.name;
|
|
}
|
|
}
|
|
|
|
export class RunVersionConflictError extends RunStateMachineError {
|
|
constructor(
|
|
public readonly runId: string,
|
|
public readonly expectedVersion: number,
|
|
public readonly actualVersion: number,
|
|
) {
|
|
super(
|
|
'Run version does not match the expected version',
|
|
'RUN_VERSION_CONFLICT',
|
|
);
|
|
}
|
|
}
|
|
|
|
export class InvalidRunTransitionError extends RunStateMachineError {
|
|
constructor(
|
|
public readonly runId: string,
|
|
public readonly from: RunStatus,
|
|
public readonly to: RunStatus,
|
|
) {
|
|
super(
|
|
`Run cannot transition from ${from} to ${to}`,
|
|
'INVALID_RUN_TRANSITION',
|
|
);
|
|
}
|
|
}
|
|
|
|
export class InvalidRunAttemptTransitionError extends RunStateMachineError {
|
|
constructor(
|
|
public readonly attemptId: string,
|
|
public readonly from: RunAttemptStatus,
|
|
public readonly to: RunAttemptStatus,
|
|
) {
|
|
super(
|
|
`RunAttempt cannot transition from ${from} to ${to}`,
|
|
'INVALID_RUN_ATTEMPT_TRANSITION',
|
|
);
|
|
}
|
|
}
|
|
|
|
export class InvalidTransitionTimestampError extends RunStateMachineError {
|
|
constructor(message: string) {
|
|
super(message, 'INVALID_TRANSITION_TIMESTAMP');
|
|
}
|
|
}
|
|
|
|
export class InvalidTransitionMetadataError extends RunStateMachineError {
|
|
constructor(message: string) {
|
|
super(message, 'INVALID_TRANSITION_METADATA');
|
|
}
|
|
}
|