feat(SW-1773): add proper validation to form and query

This commit is contained in:
Christian Andolf
2025-02-27 16:28:58 +01:00
parent 21255f8557
commit c98ac88ac0
12 changed files with 74 additions and 26 deletions

View File

@@ -40,6 +40,14 @@ export function notFound(cause?: unknown) {
})
}
export function unprocessableContent(cause?: unknown) {
return new TRPCError({
code: "UNPROCESSABLE_CONTENT",
message: "Unprocessable content",
cause,
})
}
export function internalServerError(cause?: unknown) {
return new TRPCError({
code: "INTERNAL_SERVER_ERROR",
@@ -78,6 +86,8 @@ export function serverErrorByStatus(status: number, cause?: unknown) {
return notFound(cause)
case 409:
return conflictError(cause)
case 422:
return unprocessableContent(cause)
case 500:
default:
return internalServerError(cause)