From b467c85e08fa67c84fa9385ae68fa28848c9157e Mon Sep 17 00:00:00 2001 From: jahabeebs <47253537+jahabeebs@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:11:21 -0500 Subject: [PATCH] fix: stringify --- .../src/services/discordNotifier.ts | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/automated-dispute/src/services/discordNotifier.ts b/packages/automated-dispute/src/services/discordNotifier.ts index 2c78f79..b2f257f 100644 --- a/packages/automated-dispute/src/services/discordNotifier.ts +++ b/packages/automated-dispute/src/services/discordNotifier.ts @@ -1,6 +1,6 @@ import { isNativeError } from "util/types"; import type { APIEmbed, JSONEncodable } from "discord.js"; -import { Logger } from "@ebo-agent/shared"; +import { Logger, stringify } from "@ebo-agent/shared"; import { WebhookClient, WebhookMessageCreateOptions } from "discord.js"; import { NotificationFailureException } from "../exceptions/index.js"; @@ -115,26 +115,18 @@ export class DiscordNotifier implements NotificationService { if (isNativeError(err)) { return { title: `**Error:** ${err.name} - ${err.message}`, - description: `**Context:**\n\`\`\`json\n${JSON.stringify( - { - ...contextObject, - stack: err.stack, - }, - null, - 2, - )}\n\`\`\``, + description: `**Context:**\n\`\`\`json\n${stringify({ + ...contextObject, + stack: err.stack, + })}\n\`\`\``, }; } else { return { title: `**Error:** ${defaultMessage}`, - description: `**Context:**\n\`\`\`json\n${JSON.stringify( - { - ...contextObject, - error: err ? JSON.stringify(err, null, 2) : undefined, - }, - null, - 2, - )}\n\`\`\``, + description: `**Context:**\n\`\`\`json\n${stringify({ + ...contextObject, + error: err ? stringify(err) : undefined, + })}\n\`\`\``, }; } }