Learn how to handle errors and exceptions in VTEX API Core Commerce APIs to build resilient applications.
Handling errors and exceptions is essential for building resilient applications that can effectively navigate temporary restrictions from VTEX Core Commerce API's rate limits. Exception handling and error recovery mechanisms help your store respond gracefully to rate limit exceeded errors without impacting user interactions. They also minimize unnecessary retries and resource wastage by introducing appropriate wait times and contributing to responsible resource management.
To implement effective error handling in rate-limiting scenarios, consider the VTEX API response status codes article and prioritize the best practices outlined in this article, with a specific emphasis on the code families of 3xx (Redirection), 4xx (Client Errors), and 5xx (Server Errors).
Handle 3xx errors
HTTP status codes in the 3xx range are used for redirection purposes, usually demanding the user agent to take additional actions to fulfill the request.
Error code | Error handling strategies |
---|---|
308 Permanent Redirect |
|
Handle 4xx errors
HTTP status codes in the 4xx range denote client errors, typically originating from issues on the client side.
Error code | Error handling strategies |
---|---|
400 Bad Request |
|
401 Unauthorized |
|
403 Forbidden |
|
404 Not Found |
|
405 Method Not Allowed |
|
Handle 5xx errors
HTTP status codes in the 5xx range indicate server errors, revealing issues on the server side that hinder request fulfillment. Effective error handling in this category is essential for maintaining a reliable application.
Error code | Error handling strategies |
---|---|
500 Internal Server Error |
|
503 Service Unavailable |
|
504 Gateway Timeout |
|