refacto: massive use of getMessageError

This commit is contained in:
Julien Froidefond
2025-02-27 14:26:48 +01:00
parent e76b849b17
commit 246c0c650a
26 changed files with 104 additions and 101 deletions

View File

@@ -1,8 +1,8 @@
import { NextResponse } from "next/server";
import { FavoriteService } from "@/lib/services/favorite.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { ERROR_MESSAGES } from "@/constants/errorMessages";
import { AppError } from "@/utils/errors";
import { getErrorMessage } from "@/utils/errors";
export async function GET() {
try {
@@ -15,7 +15,7 @@ export async function GET() {
{
error: {
code: error.code,
message: ERROR_MESSAGES[error.code],
message: getErrorMessage(error.code),
},
},
{ status: 500 }
@@ -25,7 +25,7 @@ export async function GET() {
{
error: {
code: ERROR_CODES.FAVORITE.FETCH_ERROR,
message: ERROR_MESSAGES[ERROR_CODES.FAVORITE.FETCH_ERROR],
message: getErrorMessage(ERROR_CODES.FAVORITE.FETCH_ERROR),
},
},
{ status: 500 }
@@ -45,7 +45,7 @@ export async function POST(request: Request) {
{
error: {
code: error.code,
message: ERROR_MESSAGES[error.code],
message: getErrorMessage(error.code),
},
},
{ status: 500 }
@@ -55,7 +55,7 @@ export async function POST(request: Request) {
{
error: {
code: ERROR_CODES.FAVORITE.ADD_ERROR,
message: ERROR_MESSAGES[ERROR_CODES.FAVORITE.ADD_ERROR],
message: getErrorMessage(ERROR_CODES.FAVORITE.ADD_ERROR),
},
},
{ status: 500 }
@@ -75,7 +75,7 @@ export async function DELETE(request: Request) {
{
error: {
code: error.code,
message: ERROR_MESSAGES[error.code],
message: getErrorMessage(error.code),
},
},
{ status: 500 }
@@ -85,7 +85,7 @@ export async function DELETE(request: Request) {
{
error: {
code: ERROR_CODES.FAVORITE.DELETE_ERROR,
message: ERROR_MESSAGES[ERROR_CODES.FAVORITE.DELETE_ERROR],
message: getErrorMessage(ERROR_CODES.FAVORITE.DELETE_ERROR),
},
},
{ status: 500 }