1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 06:56:40 +07:00

added safeJson function to safely stringify data

This commit is contained in:
Fedor Katurov 2021-05-28 11:42:08 +07:00
parent 1969b2666a
commit c1fb45742e
3 changed files with 8 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import { Template } from "../../template";
import { Storage } from "../../db";
import { Event } from "../../db/postgres/entities/Event";
import logger from "../../logger";
import safeJson from "safe-json-stringify";
export class VkEventHandler<
F extends Record<string, any> = any,
@ -105,7 +106,7 @@ export class VkEventHandler<
let plain = "";
try {
plain = JSON.stringify(text);
plain = safeJson(text);
} catch (e) {
logger.warn(`createEvent: failed to stringify JSON: ${e}`, e);
plain = text.toString();