Error Handling
from terminaluse import TerminalUse, UnprocessableEntityError
client = TerminalUse()
try:
agent = client.agents.retrieve("id")
except UnprocessableEntityError as e:
print(f"Validation error: {e}")
except Exception as e:
print(f"Error: {e}")
import { TerminalUseClient, TerminalUseError } from '@terminaluse/sdk';
const client = new TerminalUseClient({
environment: process.env.TERMINALUSE_BASE_URL ?? 'https://api.terminaluse.com',
bearerAuth: { token: process.env.TERMINALUSE_API_KEY! },
});
try {
const agent = await client.agents.retrieve({ agent_id: 'id' });
} catch (e) {
if (e instanceof TerminalUseError) {
console.log(`Error ${e.statusCode}: ${e.message}`);
}
}
Retries
The SDK automatically retries on 408, 429, and 5xx errors (default: 2 retries).client = TerminalUse(max_retries=5) # or 0 to disable
const client = new TerminalUseClient({
environment: process.env.TERMINALUSE_BASE_URL ?? 'https://api.terminaluse.com',
bearerAuth: { token: process.env.TERMINALUSE_API_KEY! },
maxRetries: 5,
});