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:
parent
1969b2666a
commit
c1fb45742e
3 changed files with 8 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue