Added try catch to redis methods.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { serializeError } from 'serialize-error';
|
||||||
import { getWebsiteSession, getWebsite } from 'queries';
|
import { getWebsiteSession, getWebsite } from 'queries';
|
||||||
import { Website, Session } from '@prisma/client';
|
import { Website, Session } from '@prisma/client';
|
||||||
import { getClient, redisEnabled } from '@umami/redis-client';
|
import { getClient, redisEnabled } from '@umami/redis-client';
|
||||||
@@ -5,6 +6,7 @@ import { getClient, redisEnabled } from '@umami/redis-client';
|
|||||||
export async function fetchWebsite(websiteId: string): Promise<Website> {
|
export async function fetchWebsite(websiteId: string): Promise<Website> {
|
||||||
let website = null;
|
let website = null;
|
||||||
|
|
||||||
|
try {
|
||||||
if (redisEnabled) {
|
if (redisEnabled) {
|
||||||
const redis = getClient();
|
const redis = getClient();
|
||||||
|
|
||||||
@@ -16,6 +18,10 @@ export async function fetchWebsite(websiteId: string): Promise<Website> {
|
|||||||
if (!website || website.deletedAt) {
|
if (!website || website.deletedAt) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('FETCH WEBSITE ERROR:', serializeError(e));
|
||||||
|
}
|
||||||
|
|
||||||
return website;
|
return website;
|
||||||
}
|
}
|
||||||
@@ -23,6 +29,7 @@ export async function fetchWebsite(websiteId: string): Promise<Website> {
|
|||||||
export async function fetchSession(websiteId: string, sessionId: string): Promise<Session> {
|
export async function fetchSession(websiteId: string, sessionId: string): Promise<Session> {
|
||||||
let session = null;
|
let session = null;
|
||||||
|
|
||||||
|
try {
|
||||||
if (redisEnabled) {
|
if (redisEnabled) {
|
||||||
const redis = getClient();
|
const redis = getClient();
|
||||||
|
|
||||||
@@ -34,6 +41,10 @@ export async function fetchSession(websiteId: string, sessionId: string): Promis
|
|||||||
} else {
|
} else {
|
||||||
session = await getWebsiteSession(websiteId, sessionId);
|
session = await getWebsiteSession(websiteId, sessionId);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('FETCH SESSION ERROR:', serializeError(e));
|
||||||
|
}
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user