import {
ChatATPClient,
AuthenticationError,
NotFoundError,
RateLimitError,
ValidationError,
ServerError,
NetworkError,
} from "@chatatp/studio";
const client = new ChatATPClient({ apiKey: "chatatp_sk_..." });
try {
const agent = await client.agents.retrieve(999);
} catch (err) {
if (err instanceof AuthenticationError) {
console.error("Check your API key.");
} else if (err instanceof NotFoundError) {
console.error("Agent not found.");
} else if (err instanceof RateLimitError) {
console.error("Slow down — you've hit the rate limit.");
} else if (err instanceof ValidationError) {
console.error("Bad request:", err.payload);
} else if (err instanceof ServerError) {
console.error("ChatATP server error, try again shortly.");
} else if (err instanceof NetworkError) {
console.error("Network failure:", err.message);
} else {
throw err;
}
}