Free AI - Documentation
WebsiteDashboard
  • Welcome to Free AI!
  • Features of Free AI
  • Getting Started
  • Installation
  • Obtain Your API Key
  • Basic Usage
  • API Reference
  • Error Handling
Powered by GitBook
On this page

Was this helpful?

Error Handling

When using the Free AI package, it's essential to implement error handling to manage potential issues that may arise during API calls. Below are common errors you might encounter and how to handle the

Common Errors

Invalid API Key

  • Description: This error occurs if the provided API key is incorrect or missing.

  • Error Message: Error: Invalid API Key

  • Handling: Check if the API key is correctly set and valid.

if (error.message.includes('Invalid API Key')) {
    console.error('Please check your API key.');
}

Network Issues

  • Description: This error occurs when there are connectivity issues or the API server is down.

  • Error Message: Error: Network Error

  • Handling: Retry the request after a short delay or alert the user.

if (error.message.includes('Network Error')) {
    console.error('Network issue. Please check your connection and try again.');
}

Server Errors

  • Description: This error occurs when the server encounters an issue processing the request.

  • Error Message: Error: Internal Server Error or Error: Service Unavailable

  • Handling: Suggest trying again later or checking the status of the service.

if (error.response && error.response.status >= 500) {
    console.error('Server error. Please try again later.');
}
PreviousAPI Reference

Last updated 7 months ago

Was this helpful?