making strides in the device and link domain setup

This commit is contained in:
user
2026-03-27 23:58:06 +02:00
parent 8c45efc92e
commit c7c303a934
17 changed files with 1202 additions and 198 deletions

View File

@@ -0,0 +1,69 @@
import { FlowExecCtx } from "@/core/flow.execution.context";
import { ERROR_CODES, type Err } from "@pkg/result";
import { getError } from "@pkg/logger";
export const deviceErrors = {
dbError: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Database operation failed",
description: "Please try again later",
detail,
}),
deviceNotFound: (fctx: FlowExecCtx, id: number): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_FOUND,
message: "Device not found",
description: "The requested device does not exist",
detail: `No device found with ID: ${id}`,
}),
listFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to list devices",
description: "Try again later",
detail,
}),
createFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to create device",
description: "Try again later",
detail,
}),
updateFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to update device",
description: "Try again later",
detail,
}),
deleteFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to delete device",
description: "Try again later",
detail,
}),
deviceNotAvailable: (fctx: FlowExecCtx, id: number): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_ALLOWED,
message: "Device is not available",
description: "The device is currently busy or offline",
detail: `Device ${id} cannot be allocated in its current state`,
actionable: true,
}),
};