24 lines
757 B
TypeScript
24 lines
757 B
TypeScript
export type CompetitionCommandErrorCode =
|
|
| 'COMPETITION_NOT_FOUND'
|
|
| 'COMPETITION_TRANSACTION_UNAVAILABLE'
|
|
| 'IDEMPOTENCY_KEY_CONFLICT'
|
|
| 'INVALID_COMPETITION_COMMAND'
|
|
| 'STALE_COMPETITION_REVISION'
|
|
| 'TOURNAMENT_CODE_ASSIGNMENT_CONFLICT';
|
|
|
|
/**
|
|
* Transport-neutral command failure. Controllers may translate `httpStatus`
|
|
* directly while command handlers remain usable by jobs and migrations.
|
|
*/
|
|
export class CompetitionCommandError extends Error {
|
|
constructor(
|
|
public readonly code: CompetitionCommandErrorCode,
|
|
message: string,
|
|
public readonly httpStatus: 404 | 409 | 412 | 422 | 500,
|
|
public readonly details?: Readonly<Record<string, unknown>>,
|
|
) {
|
|
super(message);
|
|
this.name = 'CompetitionCommandError';
|
|
}
|
|
}
|