diff --git a/src/lib/types/error.ts b/src/lib/types/error.ts new file mode 100644 index 0000000..e56081a --- /dev/null +++ b/src/lib/types/error.ts @@ -0,0 +1,8 @@ +export interface ApiError { + status: number; + details: { + code: number; + msg: string; + }; + name: string; +} \ No newline at end of file diff --git a/src/routes/auth/login/+page.server.ts b/src/routes/auth/login/+page.server.ts index 2b253dd..9325408 100644 --- a/src/routes/auth/login/+page.server.ts +++ b/src/routes/auth/login/+page.server.ts @@ -2,6 +2,7 @@ import type { Actions } from './$types'; import { fail } from '@sveltejs/kit'; import { authService } from '$lib/api/services/authService.ts'; import { HttpError } from '$lib/api/httpClient.ts'; +import type { ApiError } from '$lib/types/error.ts'; export const actions:Actions = { @@ -30,8 +31,8 @@ export const actions:Actions = { return {success:true}; }catch ( error){ if (error instanceof HttpError){ - console.log(JSON.stringify(error)); - return fail(400, {message:error.details.msg}); + const apiError = error as unknown as ApiError; + return fail(400, {message:apiError.details.msg}); } }