แก้ throw error

This commit is contained in:
kittapath 2024-12-18 18:59:44 +07:00
parent 86a5cd7fb5
commit e251b16c11
2 changed files with 54 additions and 44 deletions

View file

@ -189,12 +189,12 @@ class CheckAuth {
port: process.env.REDIS_PORT,
});
const getAsync = promisify(redisClient.get).bind(redisClient);
let reply = await getAsync("org_" + keycloakId);
if (reply != null) {
reply = JSON.parse(reply);
} else {
if (!keycloakId) throw "Error calling API No KeycloakId";
try {
try {
let reply = await getAsync("org_" + keycloakId);
if (reply != null) {
reply = JSON.parse(reply);
} else {
if (!keycloakId) throw new Error("No KeycloakId provided");
const x = await new CallAPI().GetData(
{
headers: { authorization: token },
@ -212,10 +212,10 @@ class CheckAuth {
};
return data;
} catch (error) {
console.error("Error calling API:", error);
throw error;
}
} catch (error) {
console.error("Error calling API:", error);
throw error;
}
}
public async PermissionCreate(req: RequestWithUser, system: string) {