Skip to content

Commit

Permalink
fix: stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
jahabeebs committed Nov 6, 2024
1 parent 1aed46b commit b467c85
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions packages/automated-dispute/src/services/discordNotifier.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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\`\`\``,
};
}
}
Expand Down

0 comments on commit b467c85

Please sign in to comment.