Loading...
Please wait while we prepare your content
We use cookies to enhance your experience, analyze site usage, and assist in our marketing efforts. You can manage your preferences or learn more in our Cookie Policy.
The SDK throws typed errors you can catch individually for proper error handling.
| Error Class | HTTP Status | When |
|---|---|---|
| LysticaAuthError | 401 | Missing or invalid API key |
| LysticaForbiddenError | 403 | Insufficient scope or IP block |
| LysticaNotFoundError | 404 | Resource does not exist |
| LysticaValidationError | 422 | Invalid request data |
| LysticaRateLimitError | 429 | Rate limit exceeded |
| LysticaError | any | All other API errors |
| LysticaNetworkError | — | Network failure or timeout |
import {
LysticaCloud,
LysticaAuthError,
LysticaForbiddenError,
LysticaNotFoundError,
LysticaValidationError,
LysticaRateLimitError,
LysticaError,
LysticaNetworkError,
} from "lystica-cloud";
try {
const { data } = await lystica.contacts.list();
} catch (err) {
if (err instanceof LysticaAuthError) {
console.error("Invalid or expired API key");
} else if (err instanceof LysticaForbiddenError) {
console.error("Insufficient permissions");
} else if (err instanceof LysticaNotFoundError) {
console.error("Resource not found");
} else if (err instanceof LysticaValidationError) {
console.error("Invalid request data:", err.message);
} else if (err instanceof LysticaRateLimitError) {
console.error("Rate limit exceeded — slow down");
} else if (err instanceof LysticaNetworkError) {
console.error("Network failure:", err.message);
} else if (err instanceof LysticaError) {
console.error(`API error ${err.status}: ${err.message}`);
} else {
throw err;
}
}