refacto: error and types

This commit is contained in:
Julien Froidefond
2025-02-27 21:59:14 +01:00
parent ea51ff53a9
commit 279f6c6e88
37 changed files with 800 additions and 684 deletions

View File

@@ -17,6 +17,7 @@ export async function GET(
{
error: {
code: ERROR_CODES.IMAGE.FETCH_ERROR,
name: "Image fetch error",
message: getErrorMessage(ERROR_CODES.IMAGE.FETCH_ERROR),
},
},
@@ -41,6 +42,7 @@ export async function GET(
{
error: {
code: error.code,
name: "Image fetch error",
message: getErrorMessage(error.code),
},
},
@@ -51,6 +53,7 @@ export async function GET(
{
error: {
code: ERROR_CODES.IMAGE.FETCH_ERROR,
name: "Image fetch error",
message: getErrorMessage(ERROR_CODES.IMAGE.FETCH_ERROR),
},
},

View File

@@ -13,6 +13,7 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
{
error: {
code: ERROR_CODES.BOOK.PROGRESS_UPDATE_ERROR,
name: "Progress update error",
message: getErrorMessage(ERROR_CODES.BOOK.PROGRESS_UPDATE_ERROR),
},
},
@@ -29,6 +30,7 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
{
error: {
code: error.code,
name: "Progress update error",
message: getErrorMessage(error.code),
},
},
@@ -39,6 +41,7 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
{
error: {
code: ERROR_CODES.BOOK.PROGRESS_UPDATE_ERROR,
name: "Progress update error",
message: getErrorMessage(ERROR_CODES.BOOK.PROGRESS_UPDATE_ERROR),
},
},
@@ -58,6 +61,7 @@ export async function DELETE(request: NextRequest, { params }: { params: { bookI
{
error: {
code: error.code,
name: "Progress delete error",
message: getErrorMessage(error.code),
},
},
@@ -68,6 +72,7 @@ export async function DELETE(request: NextRequest, { params }: { params: { bookI
{
error: {
code: ERROR_CODES.BOOK.PROGRESS_DELETE_ERROR,
name: "Progress delete error",
message: getErrorMessage(ERROR_CODES.BOOK.PROGRESS_DELETE_ERROR),
},
},

View File

@@ -15,8 +15,9 @@ export async function GET(request: Request, { params }: { params: { bookId: stri
{
error: {
code: error.code,
name: "Book fetch error",
message: getErrorMessage(error.code),
},
} as AppError,
},
{ status: 500 }
);
@@ -25,8 +26,9 @@ export async function GET(request: Request, { params }: { params: { bookId: stri
{
error: {
code: ERROR_CODES.BOOK.NOT_FOUND,
name: "Book fetch error",
message: getErrorMessage(ERROR_CODES.BOOK.NOT_FOUND),
},
} as AppError,
},
{ status: 500 }
);