Errors
This document outlines the standard approach for handling errors in our API responses. Our error responses are structured in a JSON format, providing clear and actionable information to the client.
Error Response Format
Errors are returned in a consistent structure, making it easier for clients to parse and take appropriate actions. Here's the structure of our standard error response:
{
"errors": [
{
"message": "You don't have access to this store",
"name": "ReportedError",
"key": "errors_store_access",
"path": []
}
]
}
Fields Description
errors
: An array of error objects.message
: A human-readable message providing more details about the error.name
: The name of the error, typically a broad classification likeReportedError
.key
: A unique identifier for the error, useful for client-side parsing.path
: An array that indicates the location of the error, typically used for form validation errors.
Handling Errors
- Parse Error Response: Always check for the
errors
field in the response. - Identify Error Type: Use the
key
orname
to identify the type of error. - User Communication: Display the
message
to the user if it's intended for them. - Logging and Monitoring: Log the error details for monitoring and debugging purposes.
- Conditional Logic: Implement conditional logic based on
key
to handle specific errors uniquely.