fix: implement error forwarder in user session module

This commit is contained in:
rafiarrafif
2025-05-27 22:51:08 +07:00
parent 85bc85618b
commit 90302eab6c
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { AppError } from "../../../helpers/error/instances/app";
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
import { findUniqueUserSessionInDBRepo } from "../repositories/findUniqueUserSessionInDB.repository";
export const getUserSessionFromDBService = async (identifier: string) => {
@ -18,6 +18,6 @@ export const getUserSessionFromDBService = async (identifier: string) => {
return userSession;
} catch (error) {
// If any DB error occurs, throw an AppError
throw new AppError(401, "Unable to get user session", error);
ErrorForwarder(error, 401, "Unable to get user session");
}
};

View File

@ -1,6 +1,6 @@
import { Prisma } from "@prisma/client";
import { AppError } from "../../../helpers/error/instances/app";
import { storeUserSessionToCacheRepo } from "../repositories/storeUserSessionToCache.repository";
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
export const storeUserSessionToCacheService = async (
userSession: Prisma.UserSessionUncheckedCreateInput,
@ -12,6 +12,6 @@ export const storeUserSessionToCacheService = async (
return;
} catch (error) {
// If any error occurs while storing session in cache, throw an AppError
throw new AppError(401, "Failed to store user session to cache");
ErrorForwarder(error, 401, "Failed to store user session to cache");
}
};