diff --git a/lib/helpers/safeParseJSON.ts b/lib/helpers/safeParseJSON.ts index f86e8539e0..3681e42273 100644 --- a/lib/helpers/safeParseJSON.ts +++ b/lib/helpers/safeParseJSON.ts @@ -3,6 +3,12 @@ export default function parseJSONSafely(str: string) { return JSON.parse(str); } catch (e) { console.error((e as Error).message); + if ((e as Error).message.includes("Unexpected token")) { + return { + success: false, + message: `Invalid JSON in the body: ${(e as Error).message}`, + }; + } return {}; } }