making strides in the device and link domain setup
This commit is contained in:
79
packages/logic/domains/link/errors.ts
Normal file
79
packages/logic/domains/link/errors.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { FlowExecCtx } from "@/core/flow.execution.context";
|
||||
import { ERROR_CODES, type Err } from "@pkg/result";
|
||||
import { getError } from "@pkg/logger";
|
||||
|
||||
export const linkErrors = {
|
||||
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,
|
||||
}),
|
||||
|
||||
linkNotFound: (fctx: FlowExecCtx, identifier: string | number): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.NOT_FOUND,
|
||||
message: "Link not found",
|
||||
description: "The requested link does not exist",
|
||||
detail: `No link found for: ${identifier}`,
|
||||
}),
|
||||
|
||||
listFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.DATABASE_ERROR,
|
||||
message: "Failed to list links",
|
||||
description: "Try again later",
|
||||
detail,
|
||||
}),
|
||||
|
||||
createFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.DATABASE_ERROR,
|
||||
message: "Failed to create link",
|
||||
description: "Try again later",
|
||||
detail,
|
||||
}),
|
||||
|
||||
updateFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.DATABASE_ERROR,
|
||||
message: "Failed to update link",
|
||||
description: "Try again later",
|
||||
detail,
|
||||
}),
|
||||
|
||||
deleteFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.DATABASE_ERROR,
|
||||
message: "Failed to delete link",
|
||||
description: "Try again later",
|
||||
detail,
|
||||
}),
|
||||
|
||||
linkNotActive: (fctx: FlowExecCtx, token: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.NOT_ALLOWED,
|
||||
message: "Link is not active",
|
||||
description: "This link has been revoked, expired, or deactivated",
|
||||
detail: `Link with token ${token} is not in an active state`,
|
||||
actionable: true,
|
||||
}),
|
||||
|
||||
linkExpired: (fctx: FlowExecCtx, token: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.NOT_ALLOWED,
|
||||
message: "Link has expired",
|
||||
description: "This link is no longer valid",
|
||||
detail: `Link with token ${token} has passed its expiry date`,
|
||||
actionable: true,
|
||||
}),
|
||||
};
|
||||
Reference in New Issue
Block a user