Files
ApiCore/ApiCore-Backend/src/hive/hive-errors.ts
T
Nick SzaunigandClaude Opus 5.5 b48fb157c8
Backend Image / build-and-push (push) Successful in 5m5s
Frontend Image / build-and-push (push) Successful in 11m2s
feat: hive setup data model and API (Beute L1)
Each colony can now hold its hive setup (Ist-Zustand) as validated
JSON with an append-only change log:

- catalog: hive systems and part types with dimensions, placement
  rules and state fields; Liebig-Zander 10 seeded with fixed ids
  (owner's equipment incl. Bausperre, Futterzarge, Nassenheider)
- pure domain module (operations, validator, derived facts) with
  shared JSON fixtures the frontend runs too
- API: catalog (hive-systems:manage), setup create/change/history/
  state at a day (colonies:read/update), 409 HIVE_CONFLICT with the
  current state, idempotent writes, HiveChanged event
- inspections can carry hive ops saved in the same transaction
- backup export/import of the new tables (backup wins per colony)
- docs: ARCHITECTURE section 13, Annahmen 95-100

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-15 21:23:23 +02:00

45 lines
1.1 KiB
TypeScript

import {
BadRequestException,
ConflictException,
NotFoundException,
} from '@nestjs/common';
import type { HiveState } from './hive-types';
/** 409: an operation failed against the current state (spec 6.2). */
export class HiveConflictException extends ConflictException {
constructor(
opIndex: number,
reason: string,
current: { version: number; state: HiveState },
) {
super({
statusCode: 409,
code: 'HIVE_CONFLICT',
message: 'Die Änderung passt nicht mehr zum aktuellen Aufbau.',
opIndex,
reason,
current,
});
}
}
export function hiveNotFound(): NotFoundException {
return new NotFoundException({
statusCode: 404,
code: 'HIVE_NOT_FOUND',
message: 'Für dieses Volk gibt es noch keinen Aufbau.',
});
}
export function hiveExists(): ConflictException {
return new ConflictException({
statusCode: 409,
code: 'HIVE_EXISTS',
message: 'Für dieses Volk gibt es schon einen Aufbau.',
});
}
export function invalidDay(field: string): BadRequestException {
return new BadRequestException(`${field} must be a valid YYYY-MM-DD day`);
}