Error Codes
Standard error response format and common error codes.
Updated
On this page
Overview
All API errors follow a consistent structure. The SDK throws errors with a message and status property.
Error Response Format
{
"error": "not_found",
"message": "Product not found",
"details": "No product with slug 'nonexistent'"
}
Catching Errors in the SDK
import dash from "@/lib/dash"
try {
const { product } = await dash.products.get("nonexistent")
} catch (error) {
console.log(error.message) // "Product not found"
console.log(error.status) // 404
}
Common Error Codes
| Error | Status | Description |
|---|---|---|
invalid_json | 400 | Malformed request body |
missing_fields | 400 | Required field missing |
validation_error | 400 | Input validation failed |
unauthorized | 401 | Missing or invalid authentication |
forbidden | 403 | Insufficient permissions |
not_found | 404 | Resource not found |
rate_limit | 429 | Too many requests |
server_error | 500 | Internal server error |
cart_not_found | 404 | Cart expired or invalid |
cart_validation_failed | 400 | Cart items have issues (out of stock) |
invalid_code | 400 | Invalid discount code |
auth_error | 401 | Authentication operation failed |
Error Handling Pattern
async function safeApiCall<T>(fn: () => Promise<T>): Promise<T | null> {
try {
return await fn()
} catch (error) {
if (error.status === 404) {
// Resource not found — show 404 page
return null
}
if (error.status === 429) {
// Rate limited — show retry message
}
throw error // Re-throw unexpected errors
}
}
Next Steps
- Rate Limits — Understanding rate limiting
- Debugging — Debugging tips
- REST API Error Responses — Full error reference