feat(i18n): first shoot on translated errors

This commit is contained in:
Julien Froidefond
2025-02-27 15:05:44 +01:00
parent 41228e59bc
commit ea51ff53a9
14 changed files with 54 additions and 38 deletions

View File

@@ -1,7 +1,6 @@
import { NextResponse } from "next/server";
import { AuthServerService } from "@/lib/services/auth-server.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { getErrorMessage } from "@/utils/errors";
import { AppError } from "@/utils/errors";
import { UserData } from "@/lib/services/auth-server.service";
@@ -23,7 +22,6 @@ export async function POST(request: Request) {
{
error: {
code: error.code,
message: getErrorMessage(error.code),
},
},
{ status: 401 }
@@ -37,7 +35,6 @@ export async function POST(request: Request) {
{
error: {
code: ERROR_CODES.AUTH.INVALID_CREDENTIALS,
message: getErrorMessage(ERROR_CODES.AUTH.INVALID_CREDENTIALS),
},
},
{ status: 500 }

View File

@@ -1,7 +1,6 @@
import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { ERROR_CODES } from "@/constants/errorCodes";
import { getErrorMessage } from "@/utils/errors";
export async function POST() {
try {
@@ -14,7 +13,6 @@ export async function POST() {
{
error: {
code: ERROR_CODES.AUTH.LOGOUT_ERROR,
message: getErrorMessage(ERROR_CODES.AUTH.LOGOUT_ERROR),
},
},
{ status: 500 }

View File

@@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
import { AuthServerService, UserData } from "@/lib/services/auth-server.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { AppError } from "@/utils/errors";
import { getErrorMessage } from "@/utils/errors";
export async function POST(request: Request) {
try {
@@ -27,7 +26,6 @@ export async function POST(request: Request) {
{
error: {
code: error.code,
message: getErrorMessage(error.code),
},
},
{ status }
@@ -41,7 +39,6 @@ export async function POST(request: Request) {
{
error: {
code: ERROR_CODES.AUTH.INVALID_USER_DATA,
message: getErrorMessage(ERROR_CODES.AUTH.INVALID_USER_DATA),
},
},
{ status: 500 }

View File

@@ -8,6 +8,8 @@ import { ErrorMessage } from "@/components/ui/ErrorMessage";
import { LibraryResponse } from "@/types/library";
import { KomgaSeries, KomgaLibrary } from "@/types/komga";
import { UserPreferences } from "@/types/preferences";
import { ERROR_CODES } from "@/constants/errorCodes";
interface PageProps {
params: { libraryId: string };
searchParams: { page?: string; unread?: string; search?: string };
@@ -90,17 +92,20 @@ async function LibraryPage({ params, searchParams }: PageProps) {
</div>
);
} catch (error) {
if (error instanceof Error) {
return (
<div className="container py-8 space-y-8">
<div className="flex items-center justify-between">
<h1 className="text-3xl font-bold">Séries</h1>
<RefreshButton libraryId={params.libraryId} refreshLibrary={refreshLibrary} />
</div>
<ErrorMessage errorCode="SERIES_FETCH_ERROR" />
</div>
);
}
return (
<div className="container py-8 space-y-8">
<div className="flex items-center justify-between">
<h1 className="text-3xl font-bold">Séries</h1>
<RefreshButton libraryId={params.libraryId} refreshLibrary={refreshLibrary} />
</div>
<ErrorMessage
message={
error instanceof Error ? error.message : "Erreur lors de la récupération des séries"
}
/>
<ErrorMessage errorCode="SERIES_FETCH_ERROR" />
</div>
);
}

View File

@@ -5,7 +5,7 @@ import { revalidatePath } from "next/cache";
import { withPageTiming } from "@/lib/hoc/withPageTiming";
import { ErrorMessage } from "@/components/ui/ErrorMessage";
import { HomeData } from "@/lib/services/home.service";
import { ERROR_CODES } from "@/constants/errorCodes";
async function refreshHome() {
"use server";
@@ -32,9 +32,7 @@ async function HomePage() {
return (
<main className="container mx-auto px-4 py-8">
<ErrorMessage
message={error instanceof Error ? error.message : "Une erreur est survenue"}
/>
<ErrorMessage errorCode="HOME_FETCH_ERROR" />
</main>
);
}

View File

@@ -78,11 +78,7 @@ async function SeriesPage({ params, searchParams }: PageProps) {
return (
<div className="container py-8 space-y-8">
<h1 className="text-3xl font-bold">Série</h1>
<ErrorMessage
message={
error instanceof Error ? error.message : "Erreur lors de la récupération de la série"
}
/>
<ErrorMessage errorCode="SERIES_FETCH_ERROR" />
</div>
);
}