fix: surface specific business-rule error messages to beekeepers

Backend business-rule guards (inactive apiary blocking colony
create/move, active colonies blocking apiary deactivation, negative
quantity on IN/OUT stock movements, unavailable queen blocking colony
assignment, inactive colony blocking split/merge/move) threw English,
UUID-laden exception text that the frontend either discarded in favor
of a generic message or - in colony-actions.tsx's move/split/merge/
assign-queen dialogs - didn't handle at all, so the guard fired with
zero visible feedback. Translated the messages to plain German and
wired the affected mutations to display them, so a beekeeper sees the
actual reason a save was rejected instead of silence or "failed".

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Sonnet 5 committed 2026-09-09 11:38:35 +02:00
1 parent de5df72491
commit 997dadfaaa
8 files changed
+37 -11

No files matched your search

@@ -86,7 +86,7 @@ export class ApiariesService {
});
if (activeColonyCount > 0) {
throw new ConflictException(
`Apiary ${id} still has ${activeColonyCount} active colonies - move or dissolve them first`,
`Der Bienenstand hat noch ${activeColonyCount} aktive(s) Volk/Völker - zuerst verlegen oder auflösen`,
);
}
const apiary = await this.prisma.apiary.update({
@@ -46,7 +46,7 @@ export class ColoniesService {
private assertActive(colony: Colony): void {
if (colony.status !== 'ACTIVE') {
throw new ConflictException(
`Colony ${colony.id} is not active (status: ${colony.status})`,
`Das Volk ist nicht aktiv (Status: ${colony.status})`,
);
}
}
@@ -61,11 +61,11 @@ export class ColoniesService {
where: { id: apiaryId },
});
if (!apiary) {
throw new NotFoundException(`Apiary ${apiaryId} not found`);
throw new NotFoundException('Bienenstand nicht gefunden');
}
if (apiary.status !== 'ACTIVE') {
throw new ConflictException(
`Apiary ${apiaryId} is not active (status: ${apiary.status})`,
'Der Bienenstand ist nicht aktiv und kann daher keine Völker aufnehmen',
);
}
}
@@ -190,7 +190,9 @@ export class ColoniesService {
where: { id: mergedColonyId },
});
if (!merged) {
throw new NotFoundException(`Colony ${mergedColonyId} not found`);
throw new NotFoundException(
'Zu vereinigendes Volk wurde nicht gefunden',
);
}
this.assertActive(merged);
// currentQueenId is unique across colonies - if it stayed set on
+1 -1
View File
@@ -157,7 +157,7 @@ export class QueensService {
const queen = await this.findById(id);
if (QUEEN_NO_LONGER_AVAILABLE_STATUSES.includes(queen.status)) {
throw new ConflictException(
`Queen ${id} is not available for assignment (status: ${queen.status}) - correct her status first if this was a mistake`,
'Die Königin ist nicht mehr verfügbar für eine Zuweisung - korrigiere zuerst ihren Status, falls dies ein Versehen war',
);
}
const colony = await this.prisma.colony.findUnique({
@@ -134,7 +134,7 @@ export class StorageService {
// that is the only way to correct a stock count downward.
if (dto.type !== 'ADJUSTMENT' && dto.quantity <= 0) {
throw new BadRequestException(
'quantity must be positive for IN/OUT movements - the direction is determined by "type"',
'Menge muss bei Eingang/Ausgang positiv sein - die Richtung wird durch den Bewegungstyp bestimmt',
);
}
const delta =