& so it begins
This commit is contained in:
59
packages/logic/domains/auth/errors.ts
Normal file
59
packages/logic/domains/auth/errors.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { FlowExecCtx } from "@/core/flow.execution.context";
|
||||
import { getError } from "@pkg/logger";
|
||||
import { ERROR_CODES, type Err } from "@pkg/result";
|
||||
|
||||
export const authErrors = {
|
||||
emailSendFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
||||
message: "Failed to send email",
|
||||
description: "An error occurred while sending the email",
|
||||
detail,
|
||||
}),
|
||||
|
||||
magicLinkEmailFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
||||
message: "Failed to send magic link email",
|
||||
description: "An error occurred while sending the magic link",
|
||||
detail,
|
||||
}),
|
||||
|
||||
emailChangeVerificationFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
||||
message: "Failed to send email change verification link",
|
||||
description: "An error occurred while sending the verification email",
|
||||
detail,
|
||||
}),
|
||||
|
||||
passwordRotationFailed: (fctx: FlowExecCtx, detail: string): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
||||
message: "Failed to begin 2FA setup",
|
||||
description: "An error occurred while rotating the password for 2FA",
|
||||
detail,
|
||||
}),
|
||||
|
||||
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,
|
||||
}),
|
||||
|
||||
accountNotFound: (fctx: FlowExecCtx): Err =>
|
||||
getError({
|
||||
flowId: fctx.flowId,
|
||||
code: ERROR_CODES.NOT_FOUND,
|
||||
message: "Account not found",
|
||||
description: "Please try again later",
|
||||
detail: "Account not found for user",
|
||||
}),
|
||||
};
|
||||
Reference in New Issue
Block a user