78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import { FlowExecCtx } from "@/core/flow.execution.context";
|
|
import { ERROR_CODES, type Err } from "@pkg/result";
|
|
import { getError } from "@pkg/logger";
|
|
|
|
export const userErrors = {
|
|
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,
|
|
}),
|
|
|
|
userNotFound: (fctx: FlowExecCtx): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.NOT_FOUND,
|
|
message: "User not found",
|
|
description: "Try with a different user id",
|
|
detail: "User not found in database",
|
|
}),
|
|
|
|
usernameCheckFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "An error occurred while checking username availability",
|
|
description: "Try again later",
|
|
detail,
|
|
}),
|
|
|
|
banOperationFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "Failed to perform ban operation",
|
|
description: "Please try again later",
|
|
detail,
|
|
}),
|
|
|
|
unbanFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "Failed to unban user",
|
|
description: "Please try again later",
|
|
detail,
|
|
}),
|
|
|
|
updateFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "Failed to update user",
|
|
description: "Please try again later",
|
|
detail,
|
|
}),
|
|
|
|
getUserInfoFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "An error occurred while getting user info",
|
|
description: "Try again later",
|
|
detail,
|
|
}),
|
|
|
|
getBanInfoFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
|
getError({
|
|
flowId: fctx.flowId,
|
|
code: ERROR_CODES.DATABASE_ERROR,
|
|
message: "An error occurred while getting ban info",
|
|
description: "Try again later",
|
|
detail,
|
|
}),
|
|
};
|