mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +01:00
Added try catch to redis methods.
This commit is contained in:
parent
aaa51e72d3
commit
0e4f4affea
1 changed files with 28 additions and 17 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue