import {
WinstonAIError,
WinstonAuthenticationError,
WinstonPaymentRequiredError,
WinstonRateLimitError,
} from "@winston-ai/ai-detector";
try {
const result = await client.detectText({ text: "Content to analyze..." });
} catch (error) {
if (error instanceof WinstonRateLimitError) {
// Back off and try again later.
} else if (error instanceof WinstonAuthenticationError) {
// Check the API key.
} else if (error instanceof WinstonPaymentRequiredError) {
// Add credits to the account.
} else if (error instanceof WinstonAIError) {
console.error(error.status, error.error, error.description);
} else {
throw error;
}
}