Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Refactor [Explicit] [LLM APIs] [Text Moderation] change errorBody (#292)
Browse files Browse the repository at this point in the history
- [+] refactor(textmoderation.ts): change errorBody from text to json and stringify errorBody in Error message
  • Loading branch information
H0llyW00dzZ authored Feb 27, 2024
1 parent 1b3eb35 commit d56af54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/client/platforms/textmoderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export async function sendModerationRequest(
});

if (!moderationResponse.ok) {
const errorBody = await moderationResponse.text(); // Attempt to read the response body
throw new Error(`[${moderationResponse.status}] Failed to get moderation response: ${errorBody}`);
// This a better way, interface error hahaaha
const errorBody = await moderationResponse.json(); // Attempt to read the response body
// Use JSON.stringify to convert the error object to a string
throw new Error(`[${moderationResponse.status}] Failed to get moderation response: ${JSON.stringify(errorBody)}`);
}

const contentType = moderationResponse.headers.get("Content-Type");
Expand Down

0 comments on commit d56af54

Please sign in to comment.