Merged in feat/LOY-158-signup-with-existing-email-error-handling (pull request #1441)
Feat/LOY-158 signup with existing email error handling * feat(LOY-158): Add handling for email conflict during signup - Implement specific error handling for email conflict in signup form - Add localized error message for existing email accounts across language dictionaries - Introduce new error type `conflictError` in trpc error handling * fix(LOY-158): revert translation changes * fix(LOY-158): Correct Finnish translation for cancellation message Approved-by: Christian Andolf
This commit is contained in:
@@ -16,6 +16,14 @@ export function forbiddenError(cause?: unknown) {
|
||||
})
|
||||
}
|
||||
|
||||
export function conflictError(cause?: unknown) {
|
||||
return new TRPCError({
|
||||
code: "CONFLICT",
|
||||
message: `Conflict`,
|
||||
cause,
|
||||
})
|
||||
}
|
||||
|
||||
export function badRequestError(cause?: unknown) {
|
||||
return new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
@@ -41,7 +49,7 @@ export function internalServerError(cause?: unknown) {
|
||||
}
|
||||
|
||||
export const SESSION_EXPIRED = "SESSION_EXPIRED"
|
||||
export class SessionExpiredError extends Error { }
|
||||
export class SessionExpiredError extends Error {}
|
||||
export function sessionExpiredError() {
|
||||
return new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
@@ -51,7 +59,7 @@ export function sessionExpiredError() {
|
||||
}
|
||||
|
||||
export const PUBLIC_UNAUTHORIZED = "PUBLIC_UNAUTHORIZED"
|
||||
export class PublicUnauthorizedError extends Error { }
|
||||
export class PublicUnauthorizedError extends Error {}
|
||||
export function publicUnauthorizedError() {
|
||||
return new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
@@ -68,6 +76,8 @@ export function serverErrorByStatus(status: number, cause?: unknown) {
|
||||
return forbiddenError(cause)
|
||||
case 404:
|
||||
return notFound(cause)
|
||||
case 409:
|
||||
return conflictError(cause)
|
||||
case 500:
|
||||
default:
|
||||
return internalServerError(cause)
|
||||
|
||||
Reference in New Issue
Block a user